外部クラス ( ) クラスで JSON データをNSObject
解析すると、解析されたデータが配列に整理されます。その配列は、テーブル ビューに配置されます。情報の解析に時間がかかるためviewDidLoad
、配列は常に nil に設定されます。
コード:
- (void)viewDidLoad
{
//Fetching Data
[super viewDidLoad];
myClass = [[MyClass alloc] init];
[myClass fetchDataWithTarget:self];
//Initialize the dataArray
dataArray = [[NSMutableArray alloc] init];
//First section data
NSArray *firstItemsArray = myClass.fechedDataArray;
NSDictionary *firstItemsArrayDict = [NSDictionary dictionaryWithObject:firstItemsArray forKey:@"data"];
[dataArray addObject:firstItemsArrayDict];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSDictionary *dictionary = [dataArray objectAtIndex:indexPath.section];
NSArray *array = [dictionary objectForKey:@"data"];
NSString *cellValue = [array objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
firstItemsArray
データがフェッチされた後に設定されていることを確認するにはどうすればよいですか。
注:テーブルビューには明らかにこれ以上のものがあります。セクションを分離するためにすべての辞書を作成しました。