0

Web サービスから受け取った NSMutableData をテーブルビューに入力したいと思います。次のコードは NSMutableData を受け入れないため、データを取得していくつかのコンポーネントで表示できますが、テーブルビューを埋めることができません。

AnyNSarray = [NSPropertyListSerialization propertyListWithData: webData options: 0 format:&plf error: &error]; 
//webData is NSMutableData that i populate with webservice data and AnyNSarray is a NSArray to provide tableview at 
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

これはテーブルビューのブロックを生成するものです(次のコードもビューの読み込み時に機能しますが、ボタンをクリックした後に再度起動されることはありません):

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = [NSString stringWithFormat:@"cell%i",indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    cell.textLabel.text = [birnsarray objectAtIndex:indexPath.row];
    cell.detailTextLabel.text = @"any details"; 
}
return cell;

}

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return AnyNSarray.count;
}
4

2 に答える 2

1
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [birnsarray count];
}
于 2013-04-18T07:13:54.017 に答える
0

numberOfRows 関数で AnyNSarray カウントを返しているので、cellForRowAtIndexPath を以下のコードに置き換えます。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = [NSString stringWithFormat:@"cell%i",indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    cell.textLabel.text = [AnyNSarray objectAtIndex:indexPath.row];
    cell.detailTextLabel.text = @"any details"; 
}
return cell;

}
于 2013-04-18T07:10:10.097 に答える