English 中文(简体)
• 要求超级?
原标题:Placing calls to super?

我以前曾提出过这个问题,但我越看其他守则的例子,我就越看到布局上的分歧。 我通常在开始时(如果是制造型方法)或最后(如果是销毁型方法)(见下文。。。。。。)尝试发出这一呼吁。

-(void)viewDidLoad {
   [super viewDidLoad];
   。。。
   。。。
}

-(void)viewDidUnload {
   。。。
   。。。
   [super viewDidUnload];
}

The other method I see always seems to place the call to super at the end of the method regardless。 (see below。。。) my question is does it matter?

-(void)viewDidLoad {
   。。。
   。。。
   [super viewDidLoad];
}

-(void)viewDidUnload {
   。。。
   。。。
   [super viewDidUnload];
}

cheers gary。

最佳回答

d 我说,除非:

  • The method is doing initialisation of instance variables (which viewDidLoad usually wouldn t be doing, as that s the init method s job), in which case the super call should be at the start.
  • The method is doing deallocation of instance variables, in which case the super call should be at the end.
  • The method is passing on some sort of event, e.g. through a responder chain, in which case you wouldn t actually be using a super call at all (but the pattern is similar), and you d put the call at the end.

不过,我可能忽略了一些重要案件。

问题回答

暂无回答




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签