1
我正在查看來自WWDC#2010的TableViewUpdates示例代碼中的TVAnimationGestures。在他們看來控制器的子類,他們有一個這樣的插座:對於UITableViewCell的子類,是否保留或分配爲該UITableViewCell的屬性
@property (nonatomic, assign) IBOutlet QuoteCell *quoteCell;
,然後在他們的cellForRowAtIndexPath創建它:
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
static NSString *QuoteCellIdentifier = @"QuoteCellIdentifier";
QuoteCell *cell = (QuoteCell*)[tableView dequeueReusableCellWithIdentifier:QuoteCellIdentifier];
if (!cell) {
UINib *quoteCellNib = [UINib nibWithNibName:@"QuoteCell" bundle:nil];
[quoteCellNib instantiateWithOwner:self options:nil];
cell = self.quoteCell;
self.quoteCell = nil;
if ([MFMailComposeViewController canSendMail]) {
UILongPressGestureRecognizer *longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
[cell addGestureRecognizer:longPressRecognizer];
[longPressRecognizer release];
}
else {
NSLog(@"Mail not available");
}
}
Play *play = (Play *)[[self.sectionInfoArray objectAtIndex:indexPath.section] play];
cell.quotation = [play.quotations objectAtIndex:indexPath.row];
return cell;
}
我的問題是,爲什麼他們所使用的屬性分配,而不是挽留?謝謝。