У меня есть следующий код для заполнения UITableView твитами.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *uniqueIdentifier = @"UITableViewCell";
UITableViewCell *cell = nil;
if(!isNewSearch) {
cell = [self.tweetsTable dequeueReusableCellWithIdentifier:uniqueIdentifier];
}
Tweet *tweet = [self.tweets objectAtIndex:[indexPath row]];
if(!cell)
{
isNewSearch = NO;
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:uniqueIdentifier] autorelease];
[[cell textLabel] setTextColor:[UIColor whiteColor]];
[[cell textLabel] setNumberOfLines:0];
[[cell textLabel] setLineBreakMode:UILineBreakModeWordWrap];
[[cell textLabel] setFont:[UIFont fontWithName:@"Futura-Medium" size:10]];
// set custom properties
}
[[cell textLabel] setText:[tweet text]];
[[cell imageView] initWithImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:tweet.profileImageUrl]]]];
return cell;
}
Приведенный выше код занимает очень много времени, так как он загружает аватары.Есть ли в любом случае я могу использовать блоки и загружать аватары в отдельном потоке и сделать интерфейс быстрее.