难以理解可可中的模式使用

时间:2011-09-05 21:29:51

标签: iphone objective-c cocoa-touch cocoa

  

可能重复:
  Objective-C: alloc of object within init of another object (memory management)
  Why does iPhone sample code use so many intermediate variables?

我在Apple的示例代码中注意到您获得了大量代码,例如:

NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] init];
self.fetchedResultsController = aFetchedResultsController;

他们为什么不这样做?:

self.fetchedResultsController = [[NSFetchedResultsController alloc] init];

和另一个例子:

UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.navigationController = aNavigationController;

而不是

self.navigationController = [[UINavigationController alloc] initWithRootViewController: rootViewController];

这对我来说似乎是不必要的一步?

谢谢。

0 个答案:

没有答案