现在的位置: 首页 > 综合 > 正文

一些Xcode升级的warning之解决

2013年12月01日 ⁄ 综合 ⁄ 共 1637字 ⁄ 字号 评论关闭

一、 Writable atomic property 'numberOfImages' cannot pair a synthesized setter/getter with a user defined setter/getter

这个是导入了OPenFlow包产生的,
查找这两个文件的头文件声明获知,这两个属性声明是这样的:
@property int number;
@propertyint numberOfImages;
可以有以下几种方法解决:
1. 声明属性为nonatomic,即我上面的修改方法。
2. @synthesize合成用getter/setter方法(即自己手动定义getter/setter方法)。
3. 用@dynamic来代替@synthesize。
4. 直接不用属性@property。

二、'&&' within '||'
问题出处:
    if (!([string characterAtIndex:0] >= '0' &&
        [string characterAtIndex:0] <= '9' || 
        [string characterAtIndex:0] == '.')) {
        return NO;
高版本更严谨了,逻辑表达式要清晰明确,更正后
    if (!(([string characterAtIndex:0] >= '0' &&
        [string characterAtIndex:0] <= '9' )|| 
        [string characterAtIndex:0] == '.')) {
        return NO;

三、Property's synthesized getter follows Cocoa naming convention for returning 'owned' objects
这个出处:@synthesize newPwd;
违犯了ARC命名规则,成员变量不要以new作为前缀。
关于ARC规则,请参考http://mobile.51cto.com/iphone-313122.htm
基本的ARC使用规则:
    1。代码中不能使用retain, release, retain, autorelease
    2。不重载dealloc(如果是释放对象内存以外的处理,是可以重载该函数的,但是不能调用[super dealloc])
    3。不能使用NSAllocateObject, NSDeallocateObject
    4。不能在C结构体中使用对象指针
    5。id与void *间的如果cast时需要用特定的方法(__bridge关键字)
    6 。不能使用NSAutoReleasePool、而需要@autoreleasepool块
    7 。不能使用“new”开始的属性名称 (如果使用会有下面的编译错误”Property’s synthesized getter follows Cocoa naming convention for returning ‘owned’ objects”)

四、warning:No previous prototype for function "randomPoint"。
你的function是在类外声明的吧,解决办法有两种:
1.在你的function前面加上static。
2.或者Project-Info -> TARGETS ->Build Settings -> LLVM GCC4.2 - Warnings组 -> Missing Function Prototypes   Yes改为No

五、 warning: 'uniqueIdentifier' is deprecated 
ios5.0已经弃用了uniqueIdentifier。如果要使用GUID,可以用apple推荐的其他办法。

或者更改iOS deployment target:iOS4.3及以前版本。

From:http://www.cocoachina.com/bbs/simple/?t103669.html

抱歉!评论已关闭.