应用程序崩溃:iphone
我有一个观点的基础iPhone应用程序
我添加了一个NSObject类AddNewContact,并采取了对象IB应用程序崩溃:iphone
AddNewContact.h
#import <Foundation/Foundation.h>
@interface AddNewContact : NSObject {
}
-(IBAction)abc:(id)sender;
@end
AddNewContact.m
#import "AddNewContact.h"
@implementation AddNewContact
-(IBAction)abc:(id)sender{
NSLog(@"this is test");
}
@end
我绑定一个UIButton的行动为abc:单击按钮时应用程序崩溃,甚至的NSLog还没有登录
但如果我绑定按钮操作的其他类函数,那么好的工作
崩溃日志
2011-06-08 15:40:30.368 myApp[5466:207] -[NSCFString abc:]: unrecognized selector sent to instance 0x6b7b1c0
2011-06-08 15:40:30.416 myApp[5466:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString abc:]: unrecognized selector sent to instance 0x6b7b1c0'
*** Call stack at first throw:
(
0 CoreFoundation 0x02ad9b99 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x02c2940e objc_exception_throw + 47
2 CoreFoundation 0x02adb6ab -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x02a4b2b6 ___forwarding___ + 966
4 CoreFoundation 0x02a4ae72 _CF_forwarding_prep_0 + 50
5 UIKit 0x0039e7f8 -[UIApplication sendAction:to:from:forEvent:] + 119
6 UIKit 0x00429de0 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x0042c262 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
8 UIKit 0x0042ae0f -[UIControl touchesEnded:withEvent:] + 458
9 UIKit 0x003c23d0 -[UIWindow _sendTouchesForEvent:] + 567
10 UIKit 0x003a3cb4 -[UIApplication sendEvent:] + 447
11 UIKit 0x003a89bf _UIApplicationHandleEvent + 7672
12 GraphicsServices 0x0306a822 PurpleEventCallback + 1550
13 CoreFoundation 0x02abaff4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
14 CoreFoundation 0x02a1b807 __CFRunLoopDoSource1 + 215
15 CoreFoundation 0x02a18a93 __CFRunLoopRun + 979
16 CoreFoundation 0x02a18350 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x02a18271 CFRunLoopRunInMode + 97
18 GraphicsServices 0x0306900c GSEventRunModal + 217
19 GraphicsServices 0x030690d1 GSEventRun + 115
20 UIKit 0x003acaf2 UIApplicationMain + 1160
21 myApp 0x00001fa4 main + 102
22 myApp 0x00001f35 start + 53
)
terminate called after throwing an instance of 'NSException'
谁能告诉我在哪里,我错了
感谢
阿米特Battan
您将发布您的AddNewContact视图控制器,该视图仍处于超视图中,但viewController已发布,该按钮尝试在AddNewContact控制器上调用'abc',该控制器不再存在...
@Simon感谢您的回复..你能告诉我在哪里/什么时候AddNewContact视图控制器被释放..作为IB的对象 – 2011-06-08 12:21:06
你可以添加代码,你创建并显示AddNewContact视图控制器吗? – 2011-06-08 12:25:57
我要在IB学习Object并改变它的课堂..检查图片... http://i.stack.imgur.com/iJJhs.png。 。 。 http://i.stack.imgur.com/CC7Zz.png ...从来没有用户AddNewContact任何地方在项目..只绑定按钮动作只有 – 2011-06-08 12:31:47
您是否连接按钮正确吗? – Anne 2011-06-08 11:34:56
嗯,我认为你没有正确地初始化你的按钮,或者你正在释放它导致问题。你粘贴你的代码初始化,以便我们可以看看它 – Robin 2011-06-08 11:35:22
@安妮是的,我正确地在IB连接.. @robin我通过IB使用按钮,所以我不认为它释放 – 2011-06-08 11:38:53