2011-12-23 3 views
1

qr codes.a를 스캔하는 프로젝트를 수행 중입니다. 이 프로젝트에서 내역 페이지이 있는데 사용자 검색 기록을 표시해야합니다. URL 만 포함되어 있습니다. 그래서 이전에 테이블 뷰에서 스캔 한 URL 목록을 표시 할 계획입니다.목표 목록에 내역 목록 저장

어떻게 기록 목록을 저장할 수 있습니까? 도와주세요. 이 같은 스캔 한 URL을 저장하기 위해 NSMutable 배열이나 다른 것을 사용할 수 있습니까 [myArray writeToURL:aURL atomically:NO];

답변

0

예를 (여기에이 샘플 코드의 배열로 에서 myArray 사용) :

테이블보기는 테이블보기의 소스로있는 NSMutableArray를 사용하는 UITableViewDataSource를 구현해야 사용자가 데이터베이스로하시면 자동 저장소를 검색하고 사용자가 역사를보고 싶어 어디 다음 데이터베이스에서 가져 오기 및

+0

hiren,이 일을하기 위해 어떤 자습서 링크를 주시겠습니까? –

+0

이 자습서를 사용해보십시오. http://www.iphonesdkarticles.com/2008/10/sqlite-tutorial-selecting-data.html – Hiren

0

가능합니다. 당신이 이것에 대한

-(void)saveToHistoryArray:(NSString *)urlAsString { 
    [myArray addObject:urlAsString]; 
    [self.tableView reloadData]; 
} 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
/* insert error checking here */ 

    return [myArray count]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if(cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    } 

    cell.textLabel.text = [myArray objectAtIndex:indexPath.row]; 

    return cell; 
} 
+0

동방의 세 박사의 단수형, 감사 F를 DISPALY하는 데 사용하는 어떤 방법을 표시 곳 sqlite가 또는 coredata를 사용하여 internel 데이터베이스를 만들 수 있습니다 또는 response.but 내가 그 배열에 내역 목록을 저장할 수있는 방법을 알고 싶습니다 –

+0

그것을 할 간단한 방법을 추가했습니다. – Magnus

0
NSString *documentsDirectory = [paths objectAtIndex:0]; 
NSString *filePath = [documentsDirectory stringByAppendingString:@"/"]; 
NSString *fullPathToFile = [filePath stringByAppendingPathComponent:@"myfile.plist"]; 
[myArray writeToFile:fullPathToFile atomically:YES];