Since when does Xcode no longer require forward method declarations and why?

╄→гoц情女王★ 提交于 2019-12-07 02:44:10

问题


I noticed that Xcode (or more precisely the Apple LLVM compiler?) does not longer require forward method declarations. In other words, the following code builds without warnings:

@implementation Foo

-(void) foo {
    [self bar];
}

-(void) bar {}

@end

This used to throw a warning in -foo saying that Foo might not respond to -bar, right? Is the compiler smarter now or is this something else? I’m using Xcode 4.3.1 plus Apple LLVM compiler 3.1.


回答1:


This has definitely changed, and it looks like such forward declarations are not required in Xcode 4.3 & later. Cf. Private Methods in Objective-C, in Xcode 4.3 I no longer need to declare them in my implementation file ?.




回答2:


In my XCode 4.2, the warning is still there, moreover, when ARC is enabled, it is an error, not just a warning.



来源:https://stackoverflow.com/questions/9884533/since-when-does-xcode-no-longer-require-forward-method-declarations-and-why

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!