Xcode常见警告汇总(持续更新)
来源:互联网 发布:知乎飞机杯 编辑:程序博客网 时间:2024/05/01 09:19
Update to recommended settings
原因:Xcode所支持的iOS版本大于工程设置的版本。
点击警告,弹出如下提示,为所有项目升级Target和Project升级版本。
或是直接在在此处逐一进行修改
Precompiled header uses DATE or TIME
解决方法:
https://github.com/ibireme/YYKit/issues/152
warning: multi-character character constant [-Wfour-char-constants]
解决方法:
http://stackoverflow.com/questions/7459939/what-do-single-quotes-do-in-c-when-used-on-multiple-characters
Comparison of integers of different signs: ‘int’ and ‘NSUInteger’ (aka ‘unsigned long’)
使用数组的,count属性的时候容易出这个问题。
for (int j = 0 ; j < [emotions count]; j++) {
}
由于数组索引不可能为负数,所以count是一个无符号整形,j是一个有符号整形。类型没有同意所以出现异常,同时, NSInteger在64位上是long 在32位上是int所以还是使用long比较保险,不会出现溢出情况。
for (unsigned long j = 0 ; j < [emotions count]; j++) { }
参考地址:
http://stackoverflow.com/questions/8350971/comparison-of-integers-of-different-signs-warning-with-xcode
Implementing deprecated method
使用了Object-C垃圾回收器不支持的方法 Objective-C garbage collection is no longer supported.
Method override for the designated initializer of the superclass ‘-init’ not found
reason:
The designated initializer guarantees the object is fully initialised by sending an initialization message to the superclass. The implementation detail becomes important to a user of the class when they subclass it. The rules for designated initializers in detail:
A designated initializer must call (via super) a designated initializer of the superclass. Where NSObject is the superclass this is just [super init].
Any convenience initializer must call another initializer in the class - which eventually leads to a designated initializer.
A class with designated initializers must implement all of the designated initializers of the superclass.
解决方法:
example:
@interface MyClass : NSObject@property(copy, nonatomic) NSString *name;-(instancetype)initWithName:(NSString *)name NS_DESIGNATED_INITIALIZER;-(instancetype)init;@end/**then the compiler checks if the (convenience) initializer init calls the (designated) initializer initWithName:, so this would cause a warning:*/-(instancetype)init{ self = [super init]; return self;}//and this would be OK:-(instancetype)init{ self = [self initWithName:@""]; return self;}
http://stackoverflow.com/questions/32741123/objective-c-warning-method-override-for-the-designated-initializer-of-the-superc
http://stackoverflow.com/questions/26185239/ios-designated-initializers-using-ns-designated-initializer
Bitmasking for introspection of Objective-C object pointers is strongly discouraged
苹果不推荐用于内省Objective-C对象指针的位掩码运算
解决方法:某数字& 0x1的时候是代表要取最低位是否为1,把(JK_EXPECT_F(((NSUInteger)object) & 0x1))
改成了 (JK_EXPECT_F(((NSUInteger)object)%2))
即可。
5enumeration values not handled in switch: ‘…
枚举里面的所有类型在switch里面并没有全部的对应起来。如果并不是都需要使用,最好是把所有的情况都补全。如果确实不需要所有功能,也应该在下面default break里面补全并打印LOG.
typedef NS_ENUM(NSInteger,AnimalName){ Dog, Cow, Hen, Cat, Pig};
下面的情况会出现警告
AnimalName animalName = Pig; switch (animalName) { case Dog: break; case Hen: break; }
添加Default警告消失
AnimalName animalName = Pig; switch (animalName) { case Dog: break; case Hen: break; default: NSLog(@"animalName is %ld",animalName); break; }
Assigning to ‘id _Nullable’ from incompatible type ‘OLLiveGiftView *const __strong’
在10.0的API中,CAAnimationDelegate变成了协议。而在iOS10以前则是以分类的形式。
iOS 9.3的代码
@property(nullable, strong) id delegate;/* When true, the animation is removed from the render tree once its * active duration has passed. Defaults to YES. */@property(getter=isRemovedOnCompletion) BOOL removedOnCompletion;@end/* Delegate methods for CAAnimation. */@interface NSObject (CAAnimationDelegate)/* Called when the animation begins its active duration. */- (void)animationDidStart:(CAAnimation *)anim;/* Called when the animation either completes its active duration or * is removed from the object it is attached to (i.e. the layer). 'flag' * is true if the animation reached the end of its active duration * without being removed. */- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag;@end
iOS10.0的代码
@property(nullable, strong) id <CAAnimationDelegate> delegate;/* When true, the animation is removed from the render tree once its * active duration has passed. Defaults to YES. */@property(getter=isRemovedOnCompletion) BOOL removedOnCompletion;@end/* Delegate methods for CAAnimation. */@protocol CAAnimationDelegate <NSObject>@optional/* Called when the animation begins its active duration. */- (void)animationDidStart:(CAAnimation *)anim;/* Called when the animation either completes its active duration or * is removed from the object it is attached to (i.e. the layer). 'flag' * is true if the animation reached the end of its active duration * without being removed. */- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag;@end
修改方法就是在类的实现里面添加协议就好。
@implementation ViewController<CAAnimationDelegate>
is deprecated: first deprecated in XXX
解决方法:方法过期使用新方法
Values of type ‘NSInteger’ should not be used as format arguments; add an explicit cast to ‘long’ instead
解决办法
[NSString stringWithFormat:@“%ld", (long)number];
接入第三方SDK异常
接入新浪微博,微信等异常,Error OSStatus -10814 ,Error 308
-canOpenURL: failed for URL: "weixin://app/wx368afdba2d19c1fa/" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.010672 MYDemo[1747:940399] -canOpenURL: failed for URL: "wtloginmqq2://qzapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.011959 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqqopensdkapiV3://qzapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.013144 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqqwpa://qzapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.014703 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqqopensdkapiV2://qzapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.015940 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqqOpensdkSSoLogin://qqapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.017359 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqq://qqapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.018724 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqzoneopensdkapiV2://qzapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.020263 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqzoneopensdkapi19://qzapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.021645 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqzoneopensdkapi://qzapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.023895 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqzoneopensdk://qzapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.025568 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqzone://qzapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.026643 MYDemo[1747:940399] -canOpenURL: failed for URL: "wtloginmqq2://qzapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.027799 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqqopensdkapiV3://qzapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.029189 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqqwpa://qzapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.032464 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqqopensdkapiV2://qzapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.034013 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqqOpensdkSSoLogin://qqapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.035385 MYDemo[1747:940399] -canOpenURL: failed for URL: "mqq://qqapp" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.067138 MYDemo[1747:940399] -canOpenURL: failed for URL: "sinaweibo://" - error: "未能完成操作。(“OSStatus”错误 -10814。)"2016-11-22 14:54:24.068271 MYDemo[1747:940399] -canOpenURL: failed for URL: "sinaweibohd://" - error: "未能完成操作。(“OSStatus”错误 -10814。)"
可以到
https://www.osstatus.com/search/results?platform=all&framework=all&search=-10814%23 查询对应的原因
解决方法:http://stackoverflow.com/questions/38689631/how-to-use-facebook-ios-sdk-on-ios-10
- Xcode常见警告汇总(持续更新)
- Xcode常见编译错误以及解决方法汇总(持续更新)
- xcode常见错误信息---持续更新
- [ios专项]Xcode 常见错误/警告,处理方法 (持续更新ing.._20140601)
- [ios专项]Xcode 常见错误/警告,处理方法 (持续更新ing.._20140601)
- 常见 bug 汇总 (持续更新)
- Xcode中快捷键汇总(持续更新中)
- gcc编程出错警告汇总(持续更新)
- iOS开发-Xcode使用技巧汇总(持续更新)
- Xcode 编译链接问题汇总(持续更新中....)
- Xcode 编译链接问题汇总(持续更新中....)
- eclipse常见异常汇总及处理(持续更新)
- 常见音频格式开源解码库汇总(持续更新)
- 【C++】C++常见面试题汇总,持续更新中...
- 有关树的常见算法汇总【持续更新中】
- 常见端口占用情况汇总(持续更新)
- 【C++】C++常见面试题汇总_持续更新中...
- python+TensorFlow常见错误汇总,持续更新中......
- Python 日期和时间
- java基础学习
- 利用scikit-learn进行人脸表面关键点的定位
- 图片鉴黄的原理和应用
- Android之用sharedUserId来实现不同应用(APK)数据共享
- Xcode常见警告汇总(持续更新)
- React Native填坑之旅--组件生命周期
- UVa 11340 Newspaper
- 完美方案——iOS的WebView自适应内容高度
- 深入理解Android输入系统
- MyBatis的foreach语句详解
- python的UML类图自动生成工具--pyreverse安装和使用
- This application is modifying the autolayout engine from a background thread after 。。。
- nyoj 找球号(二)