iOS 应用程序崩溃
我正在为 iOS 设备编写一个静态库。使用xcode 3.2.6,编译选择Latest iOS 4.3,部署选择iOS 3.1.2。保留所有默认设置,Library 使用多个框架,例如 Security。 为了测试,我首先将此库编写为应用程序,并仅在 int retVal = UIApplicationMain(argc, argv, nil, nil); 之前从主文件调用函数。所以这一切都完美地执行了。
Now if I added UI components and calling functions as per user select an option, my application starts crashing randomly or aborted abnormally.
Latest crash Log is as follows:
B61B817A-CB86-4B3D-A2BE-5CAFC9AFC857
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000012
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Application Specific Information:
objc_msgSend() selector name: objectForKey:
iPhone Simulator 238.2, iPhone OS 4.3 (iPad/8F192)
iPhone Simulator 238.2, iPhone OS 4.3 (iPad/8F192)
Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x0103109b objc_msgSend + 15
1 ??? 0x000600b8 OBJC_CLASS_$_MPLogHndlr + 0
2 iTestApp 0x0004267a -[Record2 getInfo] + 113 (Record2.m:609)
3 iTestApp 0x000434c1 -[Record2 getAllInfo:] + 44 (Record2.m:798)
4 iTestApp 0x00016919 -[BasicInfo getInfo] + 70 (BasicInfo.m:238)
5 iTestApp 0x000283bf -[AllInfo init:] + 1724 (AllInfo.m:55)
6 iTestApp 0x00012130 -[Emp getEmpInfo] + 461 (Emp.m:1175)
7 iTestApp 0x00003808 -[iTestApp ViewController btnApiGo_Clicked:] + 2155 (iTestApp ViewController.m:274)
8 UIKit 0x0032f4fd -[UIApplication sendAction:to:from:forEvent:] + 119
9 UIKit 0x003bf799 -[UIControl sendAction:to:forEvent:] + 67
10 UIKit 0x003c1c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
11 UIKit 0x003c07d8 -[UIControl touchesEnded:withEvent:] + 458
12 UIKit 0x00353ded -[UIWindow _sendTouchesForEvent:] + 567
13 UIKit 0x00334c37 -[UIApplication sendEvent:] + 447
14 UIKit 0x00339f2e _UIApplicationHandleEvent + 7576
15 GraphicsServices 0x01b18992 PurpleEventCallback + 1550
16 CoreFoundation 0x00eac944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
17 CoreFoundation 0x00e0ccf7 __CFRunLoopDoSource1 + 215
18 CoreFoundation 0x00e09f83 __CFRunLoopRun + 979
19 CoreFoundation 0x00e09840 CFRunLoopRunSpecific + 208
20 CoreFoundation 0x00e09761 CFRunLoopRunInMode + 97
21 GraphicsServices 0x01b171c4 GSEventRunModal + 217
22 GraphicsServices 0x01b17289 GSEventRun + 115
23 UIKit 0x0033dc93 UIApplicationMain + 1160
24 iTestApp 0x00001f14 main + 102 (main.m:14)
25 iTestApp 0x00001ea5 start + 53
这是代码:
- (int) getInfo
{
@try{
Field *f = [self gField:F_NAME];
int index = [self getFIndex:f];
return [f findValAtIndex:index]; <=== 609
}
@catch (NSException * e)
{
MpDebugTrace(@"Exception : <%@> %@", [e name], [e reason]);
@throw; // re-throws exception
}
return -1;
}
- (int) findValAtIndex:(int) idx
{
NSString *key = [NSString stringWithFormat:@"%d", idx];
// vals is NSMutableDictionary
NSNumber *valForKey = [vals objectForKey:key];
return [valForKey intValue];
}
I am writing a static library for iOS devices. Using xcode 3.2.6, selected Latest iOS 4.3 for compilation and selected iOS 3.1.2 for deployment. Keeping all the settings default, Library is using multiple frameworks like Security.
For testing, i first wrote this lib as application, and calling function from main file only just before int retVal = UIApplicationMain(argc, argv, nil, nil);
. So all this executed perfectly.
Now if I added UI components and calling functions as per user select an option, my application starts crashing randomly or aborted abnormally.
Latest crash Log is as follows:
B61B817A-CB86-4B3D-A2BE-5CAFC9AFC857
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000012
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Application Specific Information:
objc_msgSend() selector name: objectForKey:
iPhone Simulator 238.2, iPhone OS 4.3 (iPad/8F192)
iPhone Simulator 238.2, iPhone OS 4.3 (iPad/8F192)
Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x0103109b objc_msgSend + 15
1 ??? 0x000600b8 OBJC_CLASS_$_MPLogHndlr + 0
2 iTestApp 0x0004267a -[Record2 getInfo] + 113 (Record2.m:609)
3 iTestApp 0x000434c1 -[Record2 getAllInfo:] + 44 (Record2.m:798)
4 iTestApp 0x00016919 -[BasicInfo getInfo] + 70 (BasicInfo.m:238)
5 iTestApp 0x000283bf -[AllInfo init:] + 1724 (AllInfo.m:55)
6 iTestApp 0x00012130 -[Emp getEmpInfo] + 461 (Emp.m:1175)
7 iTestApp 0x00003808 -[iTestApp ViewController btnApiGo_Clicked:] + 2155 (iTestApp ViewController.m:274)
8 UIKit 0x0032f4fd -[UIApplication sendAction:to:from:forEvent:] + 119
9 UIKit 0x003bf799 -[UIControl sendAction:to:forEvent:] + 67
10 UIKit 0x003c1c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
11 UIKit 0x003c07d8 -[UIControl touchesEnded:withEvent:] + 458
12 UIKit 0x00353ded -[UIWindow _sendTouchesForEvent:] + 567
13 UIKit 0x00334c37 -[UIApplication sendEvent:] + 447
14 UIKit 0x00339f2e _UIApplicationHandleEvent + 7576
15 GraphicsServices 0x01b18992 PurpleEventCallback + 1550
16 CoreFoundation 0x00eac944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
17 CoreFoundation 0x00e0ccf7 __CFRunLoopDoSource1 + 215
18 CoreFoundation 0x00e09f83 __CFRunLoopRun + 979
19 CoreFoundation 0x00e09840 CFRunLoopRunSpecific + 208
20 CoreFoundation 0x00e09761 CFRunLoopRunInMode + 97
21 GraphicsServices 0x01b171c4 GSEventRunModal + 217
22 GraphicsServices 0x01b17289 GSEventRun + 115
23 UIKit 0x0033dc93 UIApplicationMain + 1160
24 iTestApp 0x00001f14 main + 102 (main.m:14)
25 iTestApp 0x00001ea5 start + 53
Here is the code :
- (int) getInfo
{
@try{
Field *f = [self gField:F_NAME];
int index = [self getFIndex:f];
return [f findValAtIndex:index]; <=== 609
}
@catch (NSException * e)
{
MpDebugTrace(@"Exception : <%@> %@", [e name], [e reason]);
@throw; // re-throws exception
}
return -1;
}
- (int) findValAtIndex:(int) idx
{
NSString *key = [NSString stringWithFormat:@"%d", idx];
// vals is NSMutableDictionary
NSNumber *valForKey = [vals objectForKey:key];
return [valForKey intValue];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论