2012-01-06 3 views
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; 
} 

私の質問はありますか?ありがとう。

答えて

0

コンセントは、ペン先からロードされたセルに簡単にアクセスできるようにするためのものです(オーナーはペン先をロードするときに自己です。これは、セルのペン先にオーナーがコントローラのクラスを表示し、セル全体のコンセントはquoteCellにリンクされます)。

これは、nibを配列にロードして最初のオブジェクトを取り出す代わりに、より便利です。

出口値は即座にnilに設定されているため、割り当てまたは保持しても差異はありません。

関連する問題