내 웹 서비스에서 데이터를 가져 오기 전에 테이블이로드되는 상황이 있습니다.connectionDidFinishLoading에서 데이터를 가져 오기 전에 UITableView가 표시됩니다.
디버그 할 때 내 NSMutableArray
에는 123 개의 개체가 있지만 테이블에 반영되지 않은 것을 볼 수 있습니다.
이 내 connectionDidFinishLoading
방법 :이 내가 갖는 내 jsonObjects
및 내 컬렉션을 채우기를 디버깅 할 경우
-(void)connectionDidFinishLoading:(NSURLConnection *)conn{
myData = [[NSString alloc] initWithData:xData encoding:NSUTF8StringEncoding];
SBJsonParser *jParser = [SBJsonParser new];
NSError *error = nil;
NSArray *jsonObjects = [jParser objectWithString:myData error:&error];
NSMutableArray *books = [[NSMutableArray alloc] init];
for(NSDictionary *dict in jsonObjects)
{
Book *b = [Book new];
b.bookName =[dict objectForKey:@"name"];
b.published = [dict objectForKey:@"published"];
[books addObject:b];
}
self.bookArray = books;
[self.tableView reloadData];
NSLog(@"myData = %@",myData);
}
. 그러나 나는 나의 테이블이 아직도 비어있는 것을 알아 차린다.
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
...
Book *b = (Book *)[self.bookArray objectAtIndex:[indexPath row]];
cell.textLabel.text = b.bookName;
....
사람이 내가 부족 무엇을 도와 수 :
그냥이 내 tableView
방법입니다 명확하게?
전체 cellForRow 메서드를 보자. rowsForSection을 구현 했습니까? – Dancreek
@Dancreek 나는 numberOfRowsForSection을 의미한다고 생각하십니까? 어쨌든, 그 그리고 [tableview reloadData] 내가 그 주제를 읽을 때 나는 나의 의혹이었다. 그는 reloadData를 호출하고 있는데, 이는 후자를 제거합니다. – barley
- (NSInteger) tableView : (UITableView *) tableView numberOfRowsInSection : (NSInteger) 섹션 { return bookArray.count; } – Matt