When I use [dic writeToFile:path atomically:YES]; I received a crash like this:
0 CoreFoundation __exceptionPreprocess (in CoreFoundation) + 124
1 libobjc.A.dylib objc_exception_throw (in libobjc.A.dylib) + 56
2 Foundation _NSErrnoMessage (in Foundation) + 0
3 CoreFoundation __CFSafelyReallocate (in CoreFoundation) + 136
4 CoreFoundation __CFDataGrow (in CoreFoundation) + 412
5 CoreFoundation CFDataReplaceBytes (in CoreFoundation) + 440
6 CoreFoundation _plistAppendCharacters (in CoreFoundation) + 180
7 CoreFoundation _CFAppendXML0 (in CoreFoundation) + 2228
8 CoreFoundation _CFAppendXML0 (in CoreFoundation) + 2720
9 CoreFoundation _CFAppendXML0 (in CoreFoundation) + 2720
10 CoreFoundation _CFPropertyListCreateXMLData (in CoreFoundation) + 216
11 CoreFoundation CFPropertyListCreateData (in CoreFoundation) + 152
12 Foundation +[NSPropertyListSerialization dataWithPropertyList:format:options:error:] (in Foundation) + 48
13 Foundation -[NSDictionary(NSDictionary) writeToFile:atomically:] (in Foundation) + 180
I think the NSDictionary contains more items ,failed when malloc memory.
How to write a large dictionary to file? or other best way?
So can someone help me please what I'm doing wrong?
Related
my application keep crashing when i try to open notifications by clicking on notification badge..i got the following crash report
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x24d33132 __exceptionPreprocess + 122
1 libobjc.A.dylib 0x32c8fc72 objc_exception_throw + 34
2 CoreFoundation 0x24d385f8 -[NSObject(NSObject) doesNotRecognizeSelector:] + 184
3 CoreFoundation 0x24d364d4 ___forwarding___ + 708
4 CoreFoundation 0x24c659d4 _CF_forwarding_prep_0 + 20
5 Skopic 0x000f7062 -[AppDelegate application:didReceiveRemoteNotification:] (AppDelegate.m:209)
6 UIKit 0x285d8c7c -[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:] + 1836
7 UIKit 0x285d06a2 -[UIApplication workspace:didReceiveActions:] + 102
8 FrontBoardServices 0x2b7ccebc __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 12
9 CoreFoundation 0x24cf9250 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 8
10 CoreFoundation 0x24cf8514 __CFRunLoopDoBlocks + 212
11 CoreFoundation 0x24cf706e __CFRunLoopRun + 1710
12 CoreFoundation 0x24c4299c CFRunLoopRunSpecific + 472
13 CoreFoundation 0x24c427ae CFRunLoopRunInMode + 102
14 GraphicsServices 0x2c3f41a4 GSEventRunModal + 132
15 UIKit 0x283cd690 UIApplicationMain + 1436
16 Skopic 0x000f46fc main (main.m:15)
17 libdyld.dylib 0x33237aaa tlv_initializer + 2
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x332fddf0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x3337ec92 pthread_kill + 58
2 libsystem_c.dylib 0x3329c934 abort + 72
3 libc++abi.dylib 0x3249bbb8 abort_message + 84
4 libc++abi.dylib 0x324b566a default_terminate_handler() + 262
5 libobjc.A.dylib 0x32c8ff0e _objc_terminate() + 190
6 libc++abi.dylib 0x324b2dec std::__terminate(void (*)()) + 76
7 libc++abi.dylib 0x324b28b4 __cxa_rethrow + 96
8 libobjc.A.dylib 0x32c8fdba objc_exception_rethrow + 38
9 CoreFoundation 0x24c42a38 CFRunLoopRunSpecific + 628
10 CoreFoundation 0x24c427ae CFRunLoopRunInMode + 102
11 GraphicsServices 0x2c3f41a4 GSEventRunModal + 132
12 UIKit 0x283cd690 UIApplicationMain + 1436
13 Skopic 0x000f46fc main (main.m:15)
14 libdyld.dylib 0x33237aac start + 0
can someone explain why these crashes keep occurring?
I don't think it makes sense to turn the NSDictionary into another NSDictionary with [NSDictionary dictionaryWithDictionary:] ... also NSDictionary can be non-nil but contain 0 key entries (an empty dictionary).
Perhaps you want: NSDictionary *apnsPayload = [userInfo objectForKey: #"alert"]; ?
See:
I got a crash log described as these:
Exception Type: SIGABRT
Exception Codes: #0 at 0x3b694350
Crashed Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[124]'
Last Exception Backtrace:
0 CoreFoundation 0x3346e2a3 __exceptionPreprocess (in CoreFoundation) + 163
1 libobjc.A.dylib 0x3b19697f objc_exception_throw (in libobjc.A.dylib) + 31
2 CoreFoundation 0x333b834d -[__NSPlaceholderArray initWithObjects:count:] (in CoreFoundation) + 165
3 CoreFoundation 0x333c6559 +[NSArray arrayWithObjects:count:] (in CoreFoundation) + 45
4 CoreFoundation 0x333d0869 -[NSDictionary allKeys] (in CoreFoundation) + 261
5 SogouInputIPhone.dylib 0x06707df1 0x66e2000 + 155121
6 SogouInputIPhone.dylib 0x066e5533 0x66e2000 + 13619
7 CoreFoundation 0x333bf037 _CFXNotificationPost (in CoreFoundation) + 1427
8 Foundation 0x33cd5599 -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation) + 73
9 UIKit 0x35301121 -[UIApplication _handleApplicationSuspend:eventInfo:] (in UIKit) + 817
10 UIKit 0x352771e7 -[UIApplication handleEvent:withNewEvent:] (in UIKit) + 2459
11 UIKit 0x352766cd -[UIApplication sendEvent:] (in UIKit) + 73
12 UIKit 0x3527611b _UIApplicationHandleEvent (in UIKit) + 6155
13 GraphicsServices 0x36f8e5a3 _PurpleEventCallback (in GraphicsServices) + 591
14 GraphicsServices 0x36f8e1d3 PurpleEventCallback (in GraphicsServices) + 35
15 CoreFoundation 0x33443173 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ (in CoreFoundation) + 35
16 CoreFoundation 0x33443117 __CFRunLoopDoSource1 (in CoreFoundation) + 139
17 CoreFoundation 0x33441f99 __CFRunLoopRun (in CoreFoundation) + 1385
18 CoreFoundation 0x333b4ebd CFRunLoopRunSpecific (in CoreFoundation) + 357
19 CoreFoundation 0x333b4d49 CFRunLoopRunInMode (in CoreFoundation) + 105
20 GraphicsServices 0x36f8d2eb GSEventRunModal (in GraphicsServices) + 75
21 UIKit 0x352ca301 UIApplicationMain (in UIKit) + 1121
22 MyApp 0x0000f94b main (in MyApp) (main.m:26)
23 libdyld.dylib 0x3b5cdb20 start (in libdyld.dylib) + 0
I have check my code, no NSArray is used.It seems that the run loop was dispatch the touch event, and generate a NSArray, but I am not sure about it and what let to the crash.
You cannot insert nil into an NSArray, if you want to put a placeholder object into your array you can use [NSNull null]. The solution to your problem is to find the nil object that you're attempting to insert and refrain from inserting it, or alloc/init it and then insert.
If you post the rest of your code we may be able to pinpoint the problem more specifically.
I'm trying to analyze a log for what appears to be an intermittent crash.
Here's the stack trace for the thread that throws the exception:
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x2ab5f49f __exceptionPreprocess + 126
1 libobjc.A.dylib 0x38315c8b objc_exception_throw + 38
2 CoreFoundation 0x2ab5f3e5 -[NSException initWithCoder:]
3 Foundation 0x2b862389 -[NSProxy doesNotRecognizeSelector:] + 68
4 CoreFoundation 0x2ab627d7 ___forwarding___ + 714
5 CoreFoundation 0x2aa94058 _CF_forwarding_prep_0 + 24
6 UIKit 0x292648cb -[UIScrollViewAccessibility _axCleanupDelegateClearer] + 98
7 UIKit 0x29264965 -[UIScrollViewAccessibility dealloc] + 60
8 UIKit 0x2e19c8b1 -[UITableView dealloc] + 1572
9 UIKit 0x2924dc91 -[UITableViewAccessibility dealloc] + 172
10 libobjc.A.dylib 0x38314da1 object_cxxDestructFromClass(objc_object*, objc_class*) + 116
11 libobjc.A.dylib 0x3831e5f7 objc_destructInstance + 34
12 libobjc.A.dylib 0x3831e61b object_dispose + 14
13 UIKit 0x2e3214d1 -[UIResponder dealloc] + 96
14 UIKit 0x2e18eb55 -[UIViewController dealloc] + 1760
15 CoreFoundation 0x2aa6600d CFRelease + 600
16 CoreFoundation 0x2aa7968f -[__NSArrayI dealloc] + 66
17 libobjc.A.dylib 0x3832fd5f objc_object::sidetable_release(bool) + 166
18 libobjc.A.dylib 0x383301a9 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 404
19 CoreFoundation 0x2aa71149 _CFAutoreleasePoolPop + 16
20 UIKit 0x2e01789f _wrapRunLoopWithAutoreleasePoolHandler + 42
21 CoreFoundation 0x2ab25d95 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
22 CoreFoundation 0x2ab23453 __CFRunLoopDoObservers + 278
23 CoreFoundation 0x2ab2385b __CFRunLoopRun + 914
24 CoreFoundation 0x2aa713c1 CFRunLoopRunSpecific + 476
25 CoreFoundation 0x2aa711d3 CFRunLoopRunInMode + 106
26 GraphicsServices 0x31e6f0a9 GSEventRunModal + 136
27 UIKit 0x2e080fa1 UIApplicationMain + 1440
28 MyApp 0x000938b1 main (main.mm:21)
29 libdyld.dylib 0x38895aaf start + 2
And here's the stack trace for the main thread:
Thread : Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x3895bdfc __pthread_kill + 8
1 libsystem_pthread.dylib 0x389d9d37 pthread_kill + 62
2 libsystem_c.dylib 0x388fb909 abort + 76
3 libc++abi.dylib 0x37c399c9 __cxa_bad_cast
4 libc++abi.dylib 0x37c53671 default_unexpected_handler()
5 libobjc.A.dylib 0x38315f25 _objc_terminate() + 192
6 libc++abi.dylib 0x37c50de3 std::__terminate(void (*)()) + 78
7 libc++abi.dylib 0x37c508af __cxa_rethrow + 102
8 libobjc.A.dylib 0x38315dd3 objc_exception_rethrow + 42
9 CoreFoundation 0x2aa7145d CFRunLoopRunSpecific + 632
10 CoreFoundation 0x2aa711d3 CFRunLoopRunInMode + 106
11 GraphicsServices 0x31e6f0a9 GSEventRunModal + 136
12 UIKit 0x2e080fa1 UIApplicationMain + 1440
13 MyApp 0x000938b1 main (main.mm:21)
Looking through the trace with the exception, I see a CF_forwarding_prep_0 message, which is followed by an [NSProxy doesNotRecognizeSelector] exception. Reading that, is it a safe assumption that the cause of the issue is that there's a pointer to a tableview delegate that isn't being set to nil? That's about the only discernible thing I see here.
Any help would be most appreciated. Thanks!
it shows error log as below, who can tell me how could I find the code where induce this crash? thanks.
my device is iphone IOS 5.0,thanks very much.
(null)
(
0 CoreFoundation 0x353aa8a7 __exceptionPreprocess + 186
1 libobjc.A.dylib 0x37751259 objc_exception_throw + 32
2 CoreFoundation 0x353aa789 +[NSException raise:format:] + 0
3 CoreFoundation 0x353aa7ab +[NSException raise:format:] + 34
4 MMBang 0x0018ccd9 MMBang + 1621209
5 libsystem_c.dylib 0x327b67e3 _sigtramp + 38
6 MMBang 0x000e9bc1 MMBang + 953281
7 CoreFoundation 0x353043fd -[NSObject performSelector:withObject:withObject:] + 52
8 MMBang 0x00094ed5 MMBang + 605909
9 CoreFoundation 0x353043fd -[NSObject performSelector:withObject:withObject:] + 52
10 MMBang 0x00093e6d MMBang + 601709
11 MMBang 0x00122ed3 MMBang + 1187539
12 CoreFoundation 0x353091fb -[NSObject performSelector:withObject:] + 42
13 Foundation 0x34ecd747 __NSThreadPerformPerform + 350
14 CoreFoundation 0x3537ead3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
15 CoreFoundation 0x3537e29f __CFRunLoopDoSources0 + 214
16 CoreFoundation 0x3537d045 __CFRunLoopRun + 652
17 CoreFoundation 0x353004a5 CFRunLoopRunSpecific + 300
18 CoreFoundation 0x3530036d CFRunLoopRunInMode + 104
19 GraphicsServices 0x36f9c439 GSEventRunModal + 136
20 UIKit 0x32e0ccd5 UIApplicationMain + 1080
21 MMBang 0x0002a583 MMBang + 169347
22 MMBang 0x00003810 MMBang + 10256
)
Go to breakpoints tab on xcode, in the bottom left hand corner there is a little plus button. Press it, click add exception breakpoint. Don't change any of the breakpoint settings and click done.
If you run your program again it should break on the line of code witch is crashing. As long as it is your code thats coursing this rather then an incorrect outlet in IB.
Hope this helps
Sam
I have the following error when I am building my app
I keep getting the same message again and again. Not sure what to do now.
Check dependencies
Internal error occurred while creating dependency graph: ASSERTION FAILURE in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-931/Xcode3Sources/XcodeIDE/Frameworks/DevToolsBase/pbxcore/Target.subproj/XCCodeSignContext.m:1237
Details: Error: failed to locate ResourceRules.plist in '/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/ResourceRules.plist' or '/Developer/Platforms/iPhoneOS.platform/ResourceRules.plist'
Object: <XCiPhoneOSCodeSignContext>
Method: +defineCodeSignAuxiliaryFilesInTargetBuildContext:
Thread: <NSThread: 0x403d5dfc0>{name = (null), num = 15}
Backtrace:
0 0x00000001137a39ac -[PBXTargetBuildContext(DependencyGraphEvents) handleFailureInMethod:object:fileName:lineNumber:messageFormat:arguments:] (in DevToolsCore)
1 0x000000010f6546a4 _DVTAssertionFailureHandler (in DVTFoundation)
2 0x000000011387c80a +[XCCodeSignContext defineCodeSignAuxiliaryFilesInTargetBuildContext:] (in DevToolsCore)
3 0x00000001137f4c10 -[XCProductTypeSpecification computeDependenciesInTargetBuildContext:] (in DevToolsCore)
4 0x0000000113884a42 -[XCNativeTargetDGSnapshot(DependencyGraphCreation) computeDependenciesInTargetBuildContext:] (in DevToolsCore)
5 0x000000011379326d -[PBXTargetBuildContext createDependencyGraphWithTargetDGSnapshot:] (in DevToolsCore)
6 0x00000001137a4a2e -[PBXTargetBuildContext(DependencyGraphEvents) dg_setTargetSnapshot:] (in DevToolsCore)
7 0x00007fff9700120c __invoking___ (in CoreFoundation)
8 0x00007fff970010a4 -[NSInvocation invoke] (in CoreFoundation)
9 0x00000001137a3df1 -[PBXTargetBuildContext(DependencyGraphEvents) processDependencyGraphEvents] (in DevToolsCore)
10 0x00007fff9700120c __invoking___ (in CoreFoundation)
11 0x00007fff970010a4 -[NSInvocation invoke] (in CoreFoundation)
12 0x00000001137ed296 -[XCInvocationQueue _processNextInvocationInThreadSlotNumber:] (in DevToolsCore)
13 0x00000001137ed6a0 -[XCInvocationQueue _processInvocationsInThreadSlotNumber:] (in DevToolsCore)
14 0x00007fff919f37fe -[NSThread main] (in Foundation)
15 0x00007fff919f3776 __NSThread__main__ (in Foundation)
16 0x00007fff965958bf _pthread_start (in libsystem_c.dylib)
17 0x00007fff96598b75 thread_start (in libsystem_c.dylib)
(null)
(
0 CoreFoundation 0x00007fff9700f286 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8de79d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff970994c9 -[NSException raise] + 9
3 DVTFoundation 0x000000010f6546a4 _DVTAssertionFailureHandler + 110
4 DevToolsCore 0x000000011387c80a +[XCCodeSignContext defineCodeSignAuxiliaryFilesInTargetBuildContext:] + 2120
5 DevToolsCore 0x00000001137f4c10 -[XCProductTypeSpecification computeDependenciesInTargetBuildContext:] + 656
6 DevToolsCore 0x0000000113884a42 -[XCNativeTargetDGSnapshot(DependencyGraphCreation) computeDependenciesInTargetBuildContext:] + 3744
7 DevToolsCore 0x000000011379326d -[PBXTargetBuildContext createDependencyGraphWithTargetDGSnapshot:] + 4889
8 DevToolsCore 0x00000001137a4a2e -[PBXTargetBuildContext(DependencyGraphEvents) dg_setTargetSnapshot:] + 460
9 CoreFoundation 0x00007fff9700120c __invoking___ + 140
10 CoreFoundation 0x00007fff970010a4 -[NSInvocation invoke] + 132
11 DevToolsCore 0x00000001137a3df1 -[PBXTargetBuildContext(DependencyGraphEvents) processDependencyGraphEvents] + 594
12 CoreFoundation 0x00007fff9700120c __invoking___ + 140
13 CoreFoundation 0x00007fff970010a4 -[NSInvocation invoke] + 132
14 DevToolsCore 0x00000001137ed296 -[XCInvocationQueue _processNextInvocationInThreadSlotNumber:] + 388
15 DevToolsCore 0x00000001137ed6a0 -[XCInvocationQueue _processInvocationsInThreadSlotNumber:] + 510
16 Foundation 0x00007fff919f37fe -[NSThread main] + 68
17 Foundation 0x00007fff919f3776 __NSThread__main__ + 1575
18 libsystem_c.dylib 0x00007fff965958bf _pthread_start + 335
19 libsystem_c.dylib 0x00007fff96598b75 thread_start + 13
)
For some reason, the files were missing. I reinstalled Xcode from the AppStore and it started working again.
I have no idea how the files were missing.