适用于 OS 2.2.1,但不适用于 OS 3.0:错误:访问器类型?
有谁知道为什么此代码在 OS 3.0 而不是 OS 2.2.1 中产生此错误?
NSUInteger aCount = [serverBrowser.servers count];
错误:访问器的类型与属性“服务器”的类型不匹配
ServerBrowser.h 在下面定义,serverBrowser 在上面的 .m 中合成。
#import <Foundation/Foundation.h>
@class ServerBrowserDelegate;
@interface ServerBrowser : NSObject {
NSMutableArray* servers;
id<ServerBrowserDelegate> delegate;
}
@property(nonatomic,readonly) NSArray* servers;
@end
预先感谢您的帮助。非常感谢。 约旦
Does Anyone have any idea why this code produces this errors in OS 3.0 and not OS 2.2.1?
NSUInteger aCount = [serverBrowser.servers count];
error: type of accessor does not match the type of property 'servers'
ServerBrowser.h is define below and serverBrowser is synthesized in .m above.
#import <Foundation/Foundation.h>
@class ServerBrowserDelegate;
@interface ServerBrowser : NSObject {
NSMutableArray* servers;
id<ServerBrowserDelegate> delegate;
}
@property(nonatomic,readonly) NSArray* servers;
@end
Thanks in advance for the help. Much appreciated.
Jordan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这与您为
servers
数组提供@property
作为NSArray*
的事实有关,但将支持实例变量声明为NSMutableArray* 。 OS 3.0 编译器可能具有比 2.2.1 更严格的编译器设置。尝试转换为:It has to do with the fact that you provide the
@property
for theservers
array as anNSArray*
, but declare the backing instance variable as anNSMutableArray*
. The OS 3.0 compiler may just come with stricter compiler settings than 2.2.1. Try converting to: