0
私はUTableViewをグループ化しています。データを「カテゴリ」グループに分割したい私はデータベース内のすべてのグループを含むインスタンス変数を持っています。インスタンス変数にアクセスできない
@interface TableViewController : UITableViewController {
// Response from server
NSString* serverResponse;
NSMutableArray *categories; // This NSMutableArray contains all category's server
}
@property (strong) NSString *serverResponse;
@property (strong) NSMutableArray *categories;
私は(すべてが完璧に動作します)requestFinished方法
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSString *result = request.responseString;
NSArray *jsonArray = (NSArray*)[result JSONValue];
int count = [jsonArray count];
int i;
NSDictionary *jsonDict = [[NSDictionary alloc] init];
for (i = 0; i < count; i++) {
jsonDict = [jsonArray objectAtIndex:i];
NSString *current = [jsonDict objectForKey:@"categoriy"];
[categories addObject:current];
NSLog(@"%d", [categories count]) // Shows 4 -> ok !
}
}
で私NSMutableArrayのを埋めるしかし、私はこの方法でそれを呼び出すとき:
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
NSLog(@"%d", [categories count]) // Show 0 -> bad !
return [categories count];
}
それはコンソル」に示し0 "!
私は本当に理由を理解できません!
おそらく誰かが私にこれを手伝うことができましたか?
完璧、両方のあなたに感謝! :) – Edelweiss