我有个问题。我从我的 URL 获取 JSON,它看起来像这样:
- (NSMutableArray *)parseObject:(NSString *)object withKey:(NSInteger)key {
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
NSString *randomKey = [standardUserDefaults stringForKey:@"randomKey"];
NSString *urlString = [NSString stringWithFormat:@"http://domain.com"];
NSURL *url = [NSURL URLWithString:urlString];
NSData *data = [NSData dataWithContentsOfURL:url];
NSError *error;
NSMutableDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSArray* latestLoans = [json objectForKey:@"object"];
NSDictionary* loan = [latestLoans objectAtIndex:key];
NSArray *myWords = [[loan objectForKey:object] componentsSeparatedByString:@","];
return myWords;
}
到我的 TableView
- (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];
}
cell.textLabel.text = [[self parseObject:@"bedrijfsnaam" withKey:0] objectAtIndex:indexPath.row];
//cell.detailTextLabel.text = [[self parseObject:@"leverunix" withKey:0] objectAtIndex:indexPath.row];
cell.textLabel.font = [UIFont systemFontOfSize:14.0];
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.numberOfLines = 3;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
它加载非常缓慢,当我想滚动时我有一种滞后。我能做些什么来让这变得更好?
谢谢