Xcode常见错误

本文介绍了在Xcode开发过程中遇到的'0.unrecognized selector sent to instance'错误,该错误通常发生在对象调用了未定义的方法时。通过检查方法名拼写、确保对象类型正确以及更新引用,可以有效解决这个问题。
摘要由CSDN通过智能技术生成

[xcode]常见错误 

错误:“0.unrecognized selector sent to instance:”

1、向一个已释放对像发送信息
2、向一个不存在的对像发送信息,特别注意,有参数的方向法名要加":"号(@seletor(dosomething:))

错误:“1.this class is not key value coding-compliant for the key ...”

1、interface build与代码中IBOutlet的连接所引起的。
2、在代码中对iboutlet的名称进行了修改,导致interface build中的连接实效。
3、如果在该viewcontroller连接的xib文件中没发现错误,那就很可能是mainWindow.xib文件中存在问题,在mainWindow.xib的tabbarcontroller的某个tab的viewcontroller设置了loadfrom"**.xib",但忘了将其class设为对应的viewcontroller类了。

错误“2.Local declaration of 'scrollView' hides instance variable” 
1、己存在一个和   'scrollView'一样的外部变量(指针)
3. 使用 main.xib时,有 报“defines presentation context is not available prior to xcode 4.2 ”的waring。
解决: 选择main.xib的 navigation controller , 然后,Development选择 Xcode 4.2
xcode 4.2 settings  errors 解决 - fay - 孤寞渡边


错误:“4.Property with 'retain (or strong)' attribute must be of object type...”
通常是声名id,int等类型当作指针导致,不要*号即可。
错误:“5.Missing file warnings” 
由于我使用了xcode自带的respositories,按照网上在终端输入指令的方法均不可行。这里我有个方法,在该项目xcode里在同一个地方新之建同一样的文件,然后在xcode里删除,即可。
错误:“6.mutating method sent to immutable object....”
mutating method(可变量对应的方法)
immutable object(不可改变的变量):
明白了吧?比如将NSMutableArray的方法用在NSArray上就会报这个错误。

错误:“7.Multiple build commands for output file”
target引用了名字重复的资源, 找到当前的target,展开之后,找到Copy Bundle Resources栏目,然后在里面找到重复名字的资源,删除不要的那个即可

Xcode 升级后,常常遇到的遇到的警告、错误,解决方法

从sdk3.2.5升级到sdk 7.1中间废弃了很多的方法,还有一些逻辑关系更加严谨了。
1,警告:“xoxoxoxo”  is deprecated
解决办法:查看xoxoxoxo的这个方法的文档,替换掉这个方法即可。

2,警告:Declaration of "struct sockaddr" will not be visible outside of this function
解决办法:在你的开源.m文件中添加 #import <netinet/in.h>

3,警告:Implicit conversion from enumeration type 'UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation'
解决办法:类型不匹配。跳到出错的那一行,UIInterfaceOrientation强制转换为UIDeviceOrientation就行了。

4,警告:incompatible pointer types assigning to 'MyArrayList*'from 'NSMutableArray'
解决办法:加入强制转换(MyArrayList*)

5,警告:'&&' within '||'
问题出处:
    if (exists && !isDirectory || !exists)………
  解决办法: if ((exists && !isDirectory) || !exists)………

6,警告:Warning:The Copy Bundle Resources build phase contains this target's Info.plist file
解决办法:将Info.plist文件移到Resources目录下,而不要直接放在target下。


7,警告:在使用ASIHttp…第三方库的,运行报错。
解决办法:看你的项目中是否添加CFNetwork.framework、SystemConfiguration.framework, MobileCoreServices.framework,
CoreGraphics.framework和libz.1.2.3.dylib,如果是sdk5.0以上,改添加libz.1.2.5.dylib

 8,警告:xxxooo,missing required architecture i386 in file 
解决办法:如果是错误信息的话:
Target->Build Settings->Search Paths, 删除Framew
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值