UITableView を設定するために使用する Web サービスから配列オブジェクトを受け取りました。Web サービスから新しい配列を取得し、テーブルにデータを入力する配列を再定義してから tableView をリロードして、この配列から新しいオブジェクトを使用するメソッドを実装しようとしています。これは、作業を行う必要があるメソッドです。
WSCaller *caller = [[WSCaller alloc]init];
arrayFromWS = [caller getArray];
[self.table reloadData];
そしてそれはうまくいきません。何か案は?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = @"productsCellIdentifier";
ProductsCell *cell = nil;
cell = (ProductsCell *)[self.table dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell)
{
NSArray *topLevelObjects = [[NSBundle mainBundle]loadNibNamed:@"ProductsCell" owner:nil options:nil];
for (id currentObject in topLevelObjects)
{
if ([currentObject isKindOfClass:[ProductsCell class]])
{
cell = (ProductsCell *)currentObject;
break;
}
}
}
if (productsMutableArray)
{
cell.backgroundColor = [UIColor whiteColor];
cell.productName.text = [[self.productsMutableArray objectAtIndex:indexPath.row]objectForKey:@"name"];
}
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [productsMutableArray count];
}