相信刚开始进行iphone开发的各位童鞋,也会跟我一样,会常常遇到一些警告或错误提示,现将问题整理如下:
1.warning: 'UIViewController' may not respond to 'xxx'
这个错误是因为ObjC语言的特点导致的,ObjC不同于Java、.net、Flex等面向对象的语言,它源于C,语法相对严格,所以定义方法的时候,若被调用方法位于调用它的方法的后面,它会找不到,就报出这样的提示。
解决方法,在.m文件开始的地方,添加
@interface UIViewController()
- (void)xxx;
@end
其中红色字段,根据所报的警告提示替换,即可。
参考帖:http://stackoverflow.com/questions/5917747/warning-uiviewcontroller-may-not-respond-to-xxx
2.warning:'format not a string literal and no format arguments'
这个错误是跟XCODE的版本有关,在XCode 3.2.1以后系统中开发时,如果使用:
NSLog([NSString stringWithFormat:@"%@ %@, %@", errorMsgFormat, error, [error userInfo]]);
输出日志,往往会出现“format not a string literal and no format arguments”警告。遇到这种情况时,只需把调用方式改成:
NSLog([NSString stringWithFormat:@"%@ %@, %@", errorMsgFormat, error, [error userInfo]], nil); 即可。
参考帖:http://sheng.iteye.com/blog/965687
3.warning:'Failed to launch simulated application: Unknown error'
有时会遇到无法使用模拟器的未知错误,这个错误的发生我也没搞明白是为什么,这时只要改变一下product的名字,一般就能解决问题。
参考帖:http://stackoverflow.com/questions/779115/iphone-failed-to-launch-simulated-application-unknown-error