从什么时候开始Xcode不再需要转发方法声明,为什么? [英] Since when does Xcode no longer require forward method declarations and why?

查看:98
本文介绍了从什么时候开始Xcode不再需要转发方法声明,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到Xcode(或更确切地说是Apple LLVM编译器?)不再需要前向方法声明.换句话说,以下代码在生成时不会发出警告:

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

这曾经在-foo中引发警告,说Foo可能不响应-bar,对吗?编译器现在更聪明了吗?还是其他呢?我正在使用Xcode 4.3.1和Apple LLVM编译器3.1.

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.

推荐答案

这肯定已经改变了,看起来Xcode 4.3&之后. cf. Objective-C中的私有方法,在Xcode 4.3中,我不再需要在实现文件中声明它们?.

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 ?.

这篇关于从什么时候开始Xcode不再需要转发方法声明,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆