Why would app try to save to PLSharedManagedObjectContext? - core-data

The following is a crash report I received from my crash reporting service, HockeyApp. The reason for the failure is a failure to save in PLSharedManagedObjectContext. I (think) I am doing all of my saves in the main app delegate managedObjectContext. Why is the PLSharedManagedObjectContext the one being saved to?
I think this is the relevant code:
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
__ENTERING_METHOD__
DLog(#"info:%#",info);
NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
__block UIImage *originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
CGSize cropSize = CGSizeMake(320,320);
CGFloat previewWindowHeight = 100.0f;
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
__block UIImage *previewImage;
if (originalImage) {
DLog(#"WE DO HAVE AN ORIGINAL IMAGE");
}
else {
DLog(#"WE DO NOT HAVE AN ORIGINAL IMAGE");
}
ImageEditor *imageEditor = [[ImageEditor alloc] initWithNibName:nil bundle:nil];
[imageEditor setRotateEnabled:NO];
[imageEditor setCheckBounds:NO];
[imageEditor setSourceImage:originalImage];
[imageEditor setPreviewHeight1:[NSNumber numberWithDouble:previewWindowHeight]];
[imageEditor setCropSize:cropSize];
imageEditor.doneCallback = ^(UIImage *editedImage, UIImage *originalImageMax1024, BOOL canceled){
picker.delegate = nil;
if(!canceled) {
if (editedImage) {
UIImage *scaledThumbnail = [HFImageEditorViewController getThumbnailForImage:editedImage size:CGSizeMake(PERSON_THUMBNAIL_SIZE,PERSON_THUMBNAIL_SIZE) round:PERSON_THUMBNAIL_ROUND];
[self setObjectCroppedImage:editedImage thumbnail:scaledThumbnail updateHeaderView:YES mocSave:NO];
[self setObjectMainImage:originalImageMax1024 mocSave:NO];
[Helper mocSave];
self.imageToShow = originalImage;
}
}
[Helper controller:self dismissControllerModal:YES];
};
[library assetForURL:assetURL resultBlock:^(ALAsset *asset) {
if (!originalImage) {
originalImage = [UIImage imageWithCGImage:[[asset defaultRepresentation] fullResolutionImage]];
}
[imageEditor setSourceImage:originalImage];
previewImage = [UIImage imageWithCGImage:[asset aspectRatioThumbnail]];
[imageEditor setPreviewImage:previewImage];
[imageEditor reset:NO];
//DLog(#"originalImage.imageOrientation:%d",originalImage.imageOrientation);
[picker pushViewController:imageEditor animated:YES];
} failureBlock:^(NSError *error) {
DLog(#"Failed to get asset from library");
if (originalImage) {
[imageEditor setSourceImage:originalImage];
[imageEditor setPreviewImage:nil];
[imageEditor reset:NO];
[picker pushViewController:imageEditor animated:YES];
}
else {
[Helper showSimpleAlertWithTitle:NSLocalizedString(#"Image Could Not Be Set", #"Image Could Not Be Set") message:NSLocalizedString(#"Failed to retrieve selected image asset from the Library.", #"Failed to retrieve selected image asset from the Library.")];
[Helper controller:self dismissControllerModal:YES];
}
}];
}
This is the crash log I am receiving:
Incident Identifier: 4DD4FE03-B8D4-4625-9039-64E4EE725AAB
CrashReporter Key: 129951E7-CF2A-4BB0-A8AB-7BA954275E29
Hardware Model: iPhone5,2
Process: MyApp [144]
Path: /Users/USER/MyApp.app/MyApp
Identifier: com.myCom.myApp
Version: 1.5.1
Code Type: ARM
Parent Process: launchd [1]
Date/Time: 2013-11-23 12:15:43 +0000
OS Version: iPhone OS 7.0.4 (11B554a)
Report Version: 104
Exception Type: SIGABRT
Exception Codes: #0 at 0x3a9031fc
Crashed Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to save context <PLSharedManagedObjectContext: 0x157b6110>: Error Domain=NSCocoaErrorDomain Code=134030 "The operation couldn’t be completed. (Cocoa error 134030.)" (null)'
Last Exception Backtrace:
0 CoreFoundation 0x2fff6e83 __exceptionPreprocess + 131
1 libobjc.A.dylib 0x3a3536c7 objc_exception_throw + 38
2 PhotoLibraryServices 0x3667441d __copy_helper_block_279 + 1
3 CoreData 0x2fdd1855 developerSubmittedBlockToNSManagedObjectContextPerform + 89
4 libdispatch.dylib 0x3a8380af _dispatch_client_callout + 23
5 libdispatch.dylib 0x3a83a9a9 _dispatch_main_queue_callback_4CF + 268
6 CoreFoundation 0x2ffc15b1 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
7 CoreFoundation 0x2ffbfe7d __CFRunLoopRun + 1309
8 CoreFoundation 0x2ff2a471 CFRunLoopRunSpecific + 524
9 CoreFoundation 0x2ff2a253 CFRunLoopRunInMode + 106
10 GraphicsServices 0x34c642eb GSEventRunModal + 138
11 UIKit 0x327df845 UIApplicationMain + 1136
12 MyApp 0x0005b10b main (main.m:5)
13 libdyld.dylib 0x3a84cab7 start + 3
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3a9031fc __pthread_kill + 8
1 libsystem_c.dylib 0x3a8b402d abort + 76
2 MyApp 0x002235c7 uncaught_exception_handler + 27
3 CoreFoundation 0x2fff7185 __handleUncaughtException + 581
4 libobjc.A.dylib 0x3a353927 _objc_terminate() + 175
5 libc++abi.dylib 0x39d191b3 std::__terminate(void (*)()) + 79
6 libc++abi.dylib 0x39d18a09 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 1
7 libobjc.A.dylib 0x3a35379b objc_exception_throw + 250
8 PhotoLibraryServices 0x3667441d __copy_helper_block_279 + 1
9 CoreData 0x2fdd1855 developerSubmittedBlockToNSManagedObjectContextPerform + 89
10 libdispatch.dylib 0x3a8380af _dispatch_client_callout + 23
11 libdispatch.dylib 0x3a83a9a9 _dispatch_main_queue_callback_4CF + 268
12 CoreFoundation 0x2ffc15b1 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 CoreFoundation 0x2ffbfe7d __CFRunLoopRun + 1309
14 CoreFoundation 0x2ff2a471 CFRunLoopRunSpecific + 524
15 CoreFoundation 0x2ff2a253 CFRunLoopRunInMode + 106
16 GraphicsServices 0x34c642eb GSEventRunModal + 138
17 UIKit 0x327df845 UIApplicationMain + 1136
18 MyApp 0x0005b10b main (main.m:5)
19 libdyld.dylib 0x3a84cab7 start + 3
Thread 1:
0 libsystem_kernel.dylib 0x3a8f0838 kevent64 + 24
1 libdispatch.dylib 0x3a839623 _dispatch_mgr_thread + 39
Thread 2:
0 libsystem_kernel.dylib 0x3a8f0a84 mach_msg_trap + 20
1 CoreFoundation 0x2ffc1559 __CFRunLoopServiceMachPort + 157
2 CoreFoundation 0x2ffbfc79 __CFRunLoopRun + 793
3 CoreFoundation 0x2ff2a471 CFRunLoopRunSpecific + 524
4 CoreFoundation 0x2ff6e0db CFRunLoopRun + 98
5 CoreMotion 0x305e2369 CLSF_thorntonUpdate_6x6 + 57225
6 libsystem_pthread.dylib 0x3a969c5d _pthread_body + 141
7 libsystem_pthread.dylib 0x3a969bcf _pthread_start + 102
8 libsystem_pthread.dylib 0x3a967cd0 thread_start + 8
Thread 3:
0 libsystem_kernel.dylib 0x3a903c7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x3a967cc4 start_wqthread + 8
Thread 4:
0 libsystem_kernel.dylib 0x3a903c7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x3a967cc4 start_wqthread + 8
Thread 5:
0 libsystem_kernel.dylib 0x3a8f0a84 mach_msg_trap + 20
1 CoreFoundation 0x2ffc1559 __CFRunLoopServiceMachPort + 157
2 CoreFoundation 0x2ffbfc79 __CFRunLoopRun + 793
3 CoreFoundation 0x2ff2a471 CFRunLoopRunSpecific + 524
4 CoreFoundation 0x2ff2a253 CFRunLoopRunInMode + 106
5 Foundation 0x309654c1 +[NSURLConnection _resourceLoadLoop:] + 320
6 Foundation 0x309dac37 __NSThread__main__ + 1063
7 libsystem_pthread.dylib 0x3a969c5d _pthread_body + 141
8 libsystem_pthread.dylib 0x3a969bcf _pthread_start + 102
9 libsystem_pthread.dylib 0x3a967cd0 thread_start + 8
Thread 6:
0 libsystem_kernel.dylib 0x3a903440 __select + 20
1 libsystem_pthread.dylib 0x3a969c5d _pthread_body + 141
2 libsystem_pthread.dylib 0x3a969bcf _pthread_start + 102
3 libsystem_pthread.dylib 0x3a967cd0 thread_start + 8
Thread 7:
0 libsystem_kernel.dylib 0x3a903c7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x3a967cc4 start_wqthread + 8
Thread 8:
0 libsystem_kernel.dylib 0x3a8f0ad4 semaphore_wait_trap + 8
1 MediaToolbox 0x31419a0f fpa_AsyncMovieControlThread + 1755
2 CoreMedia 0x30556217 figThreadMain + 195
3 libsystem_pthread.dylib 0x3a969c5d _pthread_body + 141
4 libsystem_pthread.dylib 0x3a969bcf _pthread_start + 102
5 libsystem_pthread.dylib 0x3a967cd0 thread_start + 8
Thread 9:
0 libsystem_kernel.dylib 0x3a903c7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x3a967cc4 start_wqthread + 8
Thread 0 crashed with ARM Thread State:
pc: 0x3a9031fc r7: 0x27dae3a4 sp: 0x27dae398 r0: 0x00000000
r1: 0x00000000 r2: 0x00000000 r3: 0xffffffff r4: 0x00000006
r5: 0x3c73018c r6: 0x15734ff0 r8: 0x32d7cdb2 r9: 0x3c730e30
r10: 0x32d62122 r11: 0x0000000e ip: 0x00000148 lr: 0x3a96aa53
cpsr: 0x00000010
EDIT: I think this code in ImageEditor may have something to do with it:
- (IBAction)doneAction:(id)sender
{
__ENTERING_METHOD__
self.view.userInteractionEnabled = NO;
[self startTransformHook];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
CGImageRef resultRef = [HFImageEditorViewController newTransformedImage:self.imageView.transform sourceImage:self.sourceImage.CGImage sourceSize:self.sourceImage.size sourceOrientation:self.sourceImage.imageOrientation outputWidth:self.outputWidth ? self.outputWidth : self.sourceImage.size.width cropSize:self.cropSize imageViewSize:self.imageView.bounds.size];
dispatch_async(dispatch_get_main_queue(), ^{
UIImage *transform = [UIImage imageWithCGImage:resultRef scale:1.0 orientation:UIImageOrientationUp];
CGImageRelease(resultRef);
UIImage *scaledThumbnail = [HFImageEditorViewController getThumbnailForImage:transform size:_thumbnailSize round:_thumbnailRound];
self.view.userInteractionEnabled = YES;
if(self.doneCallback) {
self.doneCallback(transform, _sourceImage, NO);
}
[self endTransformHook];
});
});
}
+ (UIImage*)getThumbnailForImage:(UIImage*)mySourceImage size:(CGSize)size round:(BOOL)round {
//TODO THIS SHOULD BE MOVED TO THE BACKGROUND
UIImage *scaledImage = [HFImageEditorViewController scaledImage:mySourceImage toSize:size withQuality:kCGInterpolationHigh];
if (round) {
CALayer *imageLayer = [CALayer layer];
imageLayer.frame = CGRectMake(0, 0, scaledImage.size.width, scaledImage.size.height);
imageLayer.contents = (id) scaledImage.CGImage;
imageLayer.masksToBounds = YES;
imageLayer.cornerRadius = scaledImage.size.width/2;
UIGraphicsBeginImageContext(scaledImage.size);
[imageLayer renderInContext:UIGraphicsGetCurrentContext()];
scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
return scaledImage;
}

PLSharedManagedObjectContext appears to be an undocumented class that's part of PhotoLibraryServices.framework. That framework is itself undocumented, but the fact that it shows up in your backtrace implicates it.
As a result I don't think that this exception has anything really to do with your Core Data code. PhotoLibraryServices is using Core Data internally somewhere, and failing to do so. This might mean that you're doing something wrong with your photo handling, or it might be a framework bug. Either way, looking at your own Core Data code will almost certainly miss the point.
Having said that, there's also an indication that a performBlock call might have been involved somehow. Depending on what your mocSave method does, there might be a connection.

Related

ios15,WKWebView,UITextField crash

iOS15 system:
1.click UITextField crash
2.Click the second layer WebView to crash
log:
Incident Identifier: 4F61CB1C-53DB-4EFD-B38F-93B973BE5CCC
CrashReporter Key: 6fa29e4a6b7c708a032c474dff75ab04a89a6a5e Hardware
Model: iPhone12,5 Process: AppName [2986] Path:
/private/var/containers/Bundle/Application/***/AppName.app/AppName
Identifier: com.***** Version: 8.0.0 (1) Code Type: ARM-64 (Native)
Role: Foreground Parent Process: launchd [1] Coalition: com.*****
[1262] Date/Time: 2022-01-28 16:14:58.8262 +0800 Launch Time:
2022-01-28 16:14:41.9927 +0800 OS Version: iPhone OS 15.2.1 (19C63)
Release Type: User Baseband Version: 3.01.02 Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes:
0x0000000000000001, 0x00000001812e01ec Exception Note:
EXC_CORPSE_NOTIFY Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: 888 handler [2986] Triggered by Thread: 0 Thread
0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0
CoreFoundation 0x1812e01ec __NSI0 + 748 1 CoreFoundation 0x181333ad4
-[NSInvocation getArgument:atIndex:] + 148 2 Foundation 0x182b4f0dc _NSGetValueWithMethod + 220 3 Foundation 0x182b0ab2c -[NSObject(NSKeyValueCoding) valueForKey:] + 320 4 AccessibilityUtilities 0x196f8787c
__57-[NSObject(UIAccessibilitySafeCategory) safeValueForKey:]_block_invoke + 40 5 AccessibilityUtilities
0x196f87640 -[NSObject(UIAccessibilitySafeCategory)
_accessibilityPerformSafeValueKeyBlock:withKey:onClass:] + 96 6 AccessibilityUtilities 0x196f879a4
-[NSObject(UIAccessibilitySafeCategory) safeValueForKey:] + 240 7 UIKit 0x1f2042e38 -[UIViewControllerAccessibility
_accessibilityLoadAccessibilityInformation] + 144 8 UIAccessibility 0x198c430e0 -[UIAccessibilityInformationLoader
_loadAccessibilityInformationOnMainThread:] + 828 9 Foundation 0x182b15780 __NSFireTimer + 104 10 CoreFoundation 0x18136e318
[CFRUN IS_CALLING_OUT_TO A_TIMER_CALLBACK_FUNCTION] + 32 11
CoreFoundation 0x1812f2cf0 __CFRunLoopDoTimer + 1076 12
CoreFoundation 0x1812ed4ec __CFRunLoopDoTimers + 328 13
CoreFoundation 0x1812cbd08 __CFRunLoopRun + 1944 14 CoreFoundation
0x1812df468 CFRunLoopRunSpecific + 600 15 GraphicsServices
0x19ce6a38c GSEventRunModal + 164 16 UIKitCore 0x183c81088
-[UIApplication _run] + 1100 17 UIKitCore 0x1839ff958 UIApplicationMain + 2092 18 AppName 0x10060fed0 main + 352 19 dyld
0x105151aa4 start + 520 .......
问题在avoidCrash中,
[AvoidCrash makeAllEffective];改成[AvoidCrash becomeEffective];不再全局捕获
发现崩溃在avoidCrashMethodSignatureForSelector:
这个方法里转发底层方法_navigationControllerContentInsetAdjustment时候崩溃

Core Data, NSPredicate causes NSInvalidArgumentException

I am calling this code on a background thread.
backgroundContext.performAndWait {
let fetchRequest:NSFetchRequest<BlogPost> = BlogPost.fetchRequest()
fetchRequest.predicate = NSPredicate.init(format: "postid=%#", argumentArray: [someInt64Value]) // this line creates an exception
_ = try? fetchRequest.execute()
....
}
If I remove the predicate, it works fine. The same predicate works just fine if used inside a fetchResultController. postid is Int64 but if I changed the predicate to any other key it would give the same NSInvalidArgumentException
This is very similar to Core Data Error - NSDate localizedCaseInsensitiveCompare: unrecognised selector sent to instance
2016-10-11 21:58:13.918 BlogClient[44494:13192129] -[_SwiftValue longLongValue]: unrecognized selector sent to instance 0x618000243cc0
2016-10-11 21:58:13.922 BlogClient[44494:13192129] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_SwiftValue longLongValue]: unrecognized selector sent to instance 0x618000243cc0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010f59534b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010ebd921e objc_exception_throw + 48
2 CoreFoundation 0x000000010f604f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010f51ac15 ___forwarding___ + 1013
4 CoreFoundation 0x000000010f51a798 _CF_forwarding_prep_0 + 120
5 CoreData 0x000000010f09762e -[NSSQLiteConnection execute] + 2270
6 CoreData 0x000000010f0aeaba newFetchedRowsForFetchPlan_MT + 1658
7 CoreData 0x000000010f274467 _executeFetchRequest + 55
8 CoreData 0x000000010f1f3be5 -[NSSQLFetchRequestContext executeRequestUsingConnection:] + 53
9 CoreData 0x000000010f220eb7 __52-[NSSQLDefaultConnectionManager handleStoreRequest:]_block_invoke + 215
10 libdispatch.dylib 0x0000000112b8b0cd _dispatch_client_callout + 8
11 libdispatch.dylib 0x0000000112b6830a _dispatch_barrier_sync_f_invoke + 340
12 CoreData 0x000000010f220d8c -[NSSQLDefaultConnectionManager handleStoreRequest:] + 236
13 CoreData 0x000000010f22861f -[NSSQLCoreDispatchManager routeStoreRequest:] + 351
14 CoreData 0x000000010f1ab7d9 -[NSSQLCore dispatchRequest:withRetries:] + 233
15 CoreData 0x000000010f1a711d -[NSSQLCore processFetchRequest:inContext:] + 93
16 CoreData 0x000000010f09dcf8 -[NSSQLCore executeRequest:withContext:error:] + 568
17 CoreData 0x000000010f191b79 __65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke + 5609
18 CoreData 0x000000010f189966 -[NSPersistentStoreCoordinator _routeHeavyweightBlock:] + 390
19 CoreData 0x000000010f09d87e -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 654
20 CoreData 0x000000010f09be24 -[NSManagedObjectContext executeFetchRequest:error:] + 548
21 CoreData 0x000000010f0e154f -[NSManagedObjectContext(_NestedContextSupport) _parentObjectsForFetchRequest:inContext:error:] + 431
22 CoreData 0x000000010f1626b3 __82-[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:]_block_invoke + 611
23 CoreData 0x000000010f0e133d internalBlockToNSManagedObjectContextPerform + 93
24 libdispatch.dylib 0x0000000112b8b0cd _dispatch_client_callout + 8
25 libdispatch.dylib 0x0000000112b6d5e5 _dispatch_barrier_sync_f_slow_invoke + 617
26 libdispatch.dylib 0x0000000112b8b0cd _dispatch_client_callout + 8
27 libdispatch.dylib 0x0000000112b6b8d6 _dispatch_main_queue_callback_4CF + 406
28 CoreFoundation 0x000000010f5594f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
29 CoreFoundation 0x000000010f51ef8d __CFRunLoopRun + 2205
30 CoreFoundation 0x000000010f51e494 CFRunLoopRunSpecific + 420
31 GraphicsServices 0x0000000113b72a6f GSEventRunModal + 161
32 UIKit 0x000000010f9b8f34 UIApplicationMain + 159
33 BlogClient 0x000000010e5a8bdf main + 111
34 libdyld.dylib 0x0000000112bd768d start + 1
35 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I found the issue. Passing an Int64 confuses the argumentArray, casting it to Int fixes the issue.
This seems to be a bug in NSPredicate() filed as radar 28749194
let id:Int64 = 5785905063264256 // Making this Int works
#objc class Test:NSObject {
let postid = id
}
let predicate = NSPredicate(format: "postid == %#"
, argumentArray: [id])
let mytest = Test()
predicate.evaluate(with: mytest) //false but should be true

UIAlertViewStyleSecureTextInput not working with ios 7

i have a issues to use a uialertView with a TextFiled in ios 7.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"title" message:nil delegate:self cancelButtonTitle:#"ok" otherButtonTitles:#"cancel", nil];
alert.alertViewStyle = UIAlertViewStyleSecureTextInput;
[[alert textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeNumberPad];
[alert show];
but in new SDK of ios 7 Creasing and Cresh Can-sol like
AssertMacros: queueEntry, file: /SourceCache/IOKitUser_Sim/IOKitUser-920.1.11/hid.subproj/IOHIDEventQueue.c, line: 512
2013-09-09 10:39:51.659 Food.de[912:a0b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]'
*** First throw call stack:
(
0 CoreFoundation 0x037a16f4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x02cc08b6 objc_exception_throw + 44
2 CoreFoundation 0x03742616 -[__NSArrayM objectAtIndex:] + 246
3 Food.de 0x0006583f -[HomeViewController addButtonToKeyboard] + 735
4 Food.de 0x00065e8e -[HomeViewController keyboardDidShow:] + 238
5 Foundation 0x02787089 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke + 40
6 CoreFoundation 0x037fd634 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
7 CoreFoundation 0x0375513b _CFXNotificationPost + 2859
8 Foundation 0x026c0de1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 98
9 UIKit 0x01cb8e97 -[UIInputViewTransition postNotificationsForTransitionEnd] + 1054
10 UIKit 0x01caf4b8 __53-[UIPeripheralHost(UIKitInternal) executeTransition:]_block_invoke1329 + 455
11 UIKit 0x0188dc15 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 306
12 UIKit 0x018778bc -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 267
13 UIKit 0x01877ba4 -[UIViewAnimationState animationDidStop:finished:] + 80
14 QuartzCore 0x00cb2e84 _ZN2CA5Layer23run_animation_callbacksEPv + 304
15 libdispatch.dylib 0x0316b4b0 _dispatch_client_callout + 14
16 libdispatch.dylib 0x03159766 _dispatch_main_queue_callback_4CF + 340
17 CoreFoundation 0x03806b6e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
18 CoreFoundation 0x037477eb __CFRunLoopRun + 1963
19 CoreFoundation 0x03746bf3 CFRunLoopRunSpecific + 467
20 CoreFoundation 0x03746a0b CFRunLoopRunInMode + 123
21 GraphicsServices 0x03e8fa27 GSEventRunModal + 192
22 GraphicsServices 0x03e8f84e GSEventRun + 104
23 UIKit 0x0182bf0b UIApplicationMain + 1225
24 Food.de 0x00006c1d main + 141
25 Food.de 0x00006b85 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
if any one develop with ios 7 and know how to solve this problem then help .
.....
if alert.alertViewStyle = UIAlertViewStyleSecureTextInput;
my xcode Version 5.0 (5A11386k)
is not working with ios 7 then we use old strategy like we do for ios 5 ?
thanks .
The problem is on your HomeViewController. You have a
[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]
This means you are trying to access an index that doesn't exists, I think on line 246

Monotouch Crash with UIWebView

I am getting random crashes with UIWebView. The only thing I have is the crash message. Hopefully this is enough to give a clue as to whats causing it. I am using my own webview delegate and subclassing SizingSource. Thanks.
Stacktrace:
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at app.Application.Main (string[]) [0x00000] in /Users/vbisbest/Projects/app/MineChat/Main.cs:17
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
Native stacktrace:
0 MineChat 0x00095f7c mono_handle_native_sigsegv + 284
1 MineChat 0x0000be98 mono_sigsegv_signal_handler + 248
2 libsystem_c.dylib 0x9a6c759b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 UIKit 0x02914aad -[UIWebViewWebViewDelegate webView:resource:didFinishLoadingFromDataSource:] + 63
5 CoreFoundation 0x0134a1bd __invoking___ + 29
6 CoreFoundation 0x0134a0d6 -[NSInvocation invoke] + 342
7 CoreFoundation 0x0134a24a -[NSInvocation invokeWithTarget:] + 74
8 WebKit 0x06b88881 -[_WebSafeForwarder forwardInvocation:] + 257
9 CoreFoundation 0x01345cf9 ___forwarding___ + 905
10 CoreFoundation 0x0134594e _CF_forwarding_prep_0 + 14
11 CoreFoundation 0x0134a1bd __invoking___ + 29
12 CoreFoundation 0x0134a0d6 -[NSInvocation invoke] + 342
13 WebCore 0x079c6483 _ZL11SendMessageP12NSInvocation + 35
14 WebCore 0x079c5ff8 _ZL20HandleDelegateSourcePv + 104
15 CoreFoundation 0x012d9f3f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16 CoreFoundation 0x012d996f __CFRunLoopDoSources0 + 239
17 CoreFoundation 0x012fc734 __CFRunLoopRun + 964
18 CoreFoundation 0x012fbf44 CFRunLoopRunSpecific + 276
19 CoreFoundation 0x012fbe1b CFRunLoopRunInMode + 123
20 GraphicsServices 0x04d237e3 GSEventRunModal + 88
21 GraphicsServices 0x04d23668 GSEventRun + 104
22 UIKit 0x0273965c UIApplicationMain + 1211
23 ??? 0x0e39bf15 0x0 + 238665493
24 ??? 0x0e398b78 0x0 + 238652280
25 ??? 0x0e397ea8 0x0 + 238649000
26 ??? 0x0e39801e 0x0 + 238649374
27 MineChat 0x00010252 mono_jit_runtime_invoke + 722
28 MineChat 0x0017478e mono_runtime_invoke + 126
29 MineChat 0x00178be4 mono_runtime_exec_main + 420
30 MineChat 0x00178f55 mono_runtime_run_main + 725
31 MineChat 0x0006ba65 mono_jit_exec + 149
32 MineChat 0x0021f65d main + 2013
33 MineChat 0x00003125 start + 53
34 ??? 0x00000004 0x0 + 4
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
void HandleLoadFinished (object sender, EventArgs e)
{
try
{
// New message has been added, customize the cell and size it properly
UIWebView webView = (UIWebView)sender;
webView.ScrollView.ScrollEnabled = false;
// Get the height of the content
float height = float.Parse(webView.EvaluateJavascript("document.height"));
// Redraw the webview frame to the size of the content
webView.Frame = new RectangleF(0,0,this.View.Frame.Width, height);
webView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
// Create the dialog element with the new view
//UIViewElement viewElement = new UIViewElement("", webView ,false);
WebViewElement viewElement = new WebViewElement("", webView ,false);
string html = webView.EvaluateJavascript("document.body.innerHTML");
viewElement.HTML = html;
viewElement.WebView = webView;
viewElement.Tapped += delegate()
{
if(MessageTapped!=null)
{
MessageTapped(viewElement.HTML);
}
};
// Add it to the section
messageSection.Add(viewElement);
CustomSizingSource customSizingSource = (CustomSizingSource)this.TableView.Source;
if(customSizingSource.PinToBottom)
{
var lastIndexPath = viewElement.IndexPath;
if(lastIndexPath!=null)
{
this.TableView.ScrollToRow( lastIndexPath, UITableViewScrollPosition.Bottom, true);
}
}
}
catch(Exception ex)
{
Console.WriteLine("Error message finished loading: " + ex.Message);
}
}

App is crashing in a certain line, Why?

My real code is full of NSLog's,
the following line is the reason for he crash but I don't understand why
NSString *newDir = [documentsDirectory
stringByAppendingPathComponent:file];
Here is the whole method:
- (void)viewDidLoad {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray* newArray= [[NSArray alloc]init];
newArray= [fileManager contentsOfDirectoryAtURL:[NSURL fileURLWithPath:#"/Users/admin/Library/FotoAppFotos/"]
includingPropertiesForKeys:[NSArray arrayWithObject:NSURLNameKey] options:NSDirectoryEnumerationSkipsHiddenFiles error:nil];
categories= [NSMutableArray arrayWithArray: newArray];
for(NSString *file in categories) {
NSString *newDir = [documentsDirectory stringByAppendingPathComponent:file]; // in this line the app crashes
[categories addObject:newDir]; //categories
}
[super viewDidLoad];
}
As mentioned the NSLog print of documentsDirectory and file are:
documentsDirectory: /Users/admin/Library/Application Support/iPhone
Simulator/4.3/Applications/D5AB6F90-0420-4A66-B141-D27AB2C11C3C/Documents
file://localhost/Users/admin/Library/FotoAppFotos/Audio/
The whole crash log is:
2011-11-09 09:21:42.989 TestTest[543:207] -[NSURL length]: unrecognized selector sent to instance 0x5c07df0
2011-11-09 09:21:42.992 TestTest[543:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL length]: unrecognized selector sent to instance 0x5c07df0'
*** Call stack at first throw:
(
0 CoreFoundation 0x0102b5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0117f313 objc_exception_throw + 44
2 CoreFoundation 0x0102d0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00f9c966 ___forwarding___ + 966
4 CoreFoundation 0x00f9c522 _CF_forwarding_prep_0 + 50
5 Foundation 0x0002b1ad -[NSPathStore2 stringByAppendingPathComponent:] + 211
6 TestTest 0x00003244 -[Produktpalette viewDidLoad] + 535
7 UIKit 0x0036f089 -[UIViewController view] + 179
8 UIKit 0x0060ca40 -[UIPopoverController _setupIncomingViewController:presenting:animated:] + 143
9 UIKit 0x0060be26 -[UIPopoverController initWithContentViewController:] + 321
10 TestTest 0x00002540 -[TestTestViewController produktpalette:] + 151
11 UIKit 0x002bf4fd -[UIApplication sendAction:to:from:forEvent:] + 119
12 UIKit 0x004d1cc3 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 156
13 UIKit 0x002bf4fd -[UIApplication sendAction:to:from:forEvent:] + 119
14 UIKit 0x0034f799 -[UIControl sendAction:to:forEvent:] + 67
15 UIKit 0x00351c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
16 UIKit 0x003507d8 -[UIControl touchesEnded:withEvent:] + 458
17 UIKit 0x002e3ded -[UIWindow _sendTouchesForEvent:] + 567
18 UIKit 0x002c4c37 -[UIApplication sendEvent:] + 447
19 UIKit 0x002c9f2e _UIApplicationHandleEvent + 7576
20 GraphicsServices 0x01983992 PurpleEventCallback + 1550
21 CoreFoundation 0x0100c944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
22 CoreFoundation 0x00f6ccf7 __CFRunLoopDoSource1 + 215
23 CoreFoundation 0x00f69f83 __CFRunLoopRun + 979
24 CoreFoundation 0x00f69840 CFRunLoopRunSpecific + 208
25 CoreFoundation 0x00f69761 CFRunLoopRunInMode + 97
26 GraphicsServices 0x019821c4 GSEventRunModal + 217
27 GraphicsServices 0x01982289 GSEventRun + 115
28 UIKit 0x002cdc93 UIApplicationMain + 1160
29 TestTest 0x00001c2a main + 84
30 TestTest 0x00001bcd start + 53
)
terminate called after throwing an instance of 'NSException'
Thank you for any help and presumption in advance
The hint comes from:
[NSURL length]: unrecognized selector sent to instance
If you are working on iOS, sorry to tell that :
This method is unimplemented in iOS, so it performs no operation.
Somebody has similar problem .

Resources