所以我正在创建一个解析JSON的应用程序并创建一个关联的UITableView。以下是一些代码:
NSData *jsonData = [json dataUsingEncoding:NSASCIIStringEncoding];
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData
options:kNilOptions
error:&error];
NSArray *tempArray = [NSArray arrayWithObjects:@"Call Support Desk", @"Call Genius Bar", nil];
for (NSString *name in [jsonDict valueForKeyPath:@"name"]) {
NSString *tempString = [[NSString alloc] initWithString:name];
Company *company = [[Company alloc] initWithName:tempString available_actions:tempArray];
[self addCompany:company];
NSLog(@"array: %@", _companyList);
当NSLog打印出阵列时,它表示有两个对象,并且具有与对象关联的所有正确数据。后来当我返回数组中的对象数(应该是2)时,它表示没有:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.dataController countOfList];
}
我是iOS编程的新手,所以我们非常感谢任何建议