iphone开发中常遇到的错误及解决方法(不断补充中⋯⋯)

本文详细解析了iPhone开发中常见的警告与错误提示,包括'UIViewController'maynotrespondto'xxx'、'formatnotastringliteralandnoformatarguments'及'Failed to launch simulated application: Unknown error'等问题的解决方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

相信刚开始进行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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值