0

This is my code:

ViewController.h

@interface ViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>

@property (retain, nonatomic) IBOutlet UITextView *messageText;
@property (retain, nonatomic) IBOutlet UIImageView *imageView;

-(IBAction)selectPhoto:(UIButton*)sender;

@end

ViewController.m

-(IBAction)selectPhoto:(UIButton *)sender
{
    /*
    UIImagePickerController* picker = [UIImagePickerController new];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    [self presentViewController:picker animated:YES completion:NULL];
     */
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    //UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
    //self.imageView.image = chosenImage;

    //[picker dismissViewControllerAnimated:YES completion:NULL];
}


- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

    //[picker dismissViewControllerAnimated:YES completion:NULL];
}

At the moment all the code is commented out, but the app still crashes. If I remove the two delegates for UIImagePickerController then the app doesn't crash anymore.

This is a screen shoot with the crash:

enter image description here

edit: Stack Trace:

* thread #3: tid = 0x1214f, 0x000000010210efcb libobjc.A.dylib`objc_msgSend + 11, queue = 'NSOperationQueue 0x10bb50dd0', stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
  * frame #0: 0x000000010210efcb libobjc.A.dylib`objc_msgSend + 11
    frame #1: 0x0000000101cce137 Foundation`_NSDescriptionWithLocaleFunc + 41
    frame #2: 0x0000000102321244 CoreFoundation`__CFStringAppendFormatCore + 7252
    frame #3: 0x000000010235f913 CoreFoundation`_CFStringCreateWithFormatAndArgumentsAux + 115
    frame #4: 0x00000001023bfa5b CoreFoundation`_CFLogvEx + 123
    frame #5: 0x0000000101cfe276 Foundation`NSLogv + 79
    frame #6: 0x0000000101cfe20a Foundation`NSLog + 148
    frame #7: 0x0000000100057726 SocialApp`__28-[GPPSignIn checkSDKVersion]_block_invoke + 439
    frame #8: 0x000000010006dfd4 SocialApp`-[GTMHTTPFetcher connectionDidFinishLoading:] + 714
    frame #9: 0x0000000101dec36b Foundation`__65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 48
    frame #10: 0x0000000101d2363b Foundation`-[NSBlockOperation main] + 75
    frame #11: 0x0000000101d71d34 Foundation`-[__NSOperationInternal _start:] + 623
    frame #12: 0x0000000101d73c0b Foundation`__NSOQSchedule_f + 64
    frame #13: 0x0000000102aa172d libdispatch.dylib`_dispatch_client_callout + 8
    frame #14: 0x0000000102a8feab libdispatch.dylib`_dispatch_async_redirect_invoke + 174
    frame #15: 0x0000000102aa172d libdispatch.dylib`_dispatch_client_callout + 8
    frame #16: 0x0000000102a91b27 libdispatch.dylib`_dispatch_root_queue_drain + 380
    frame #17: 0x0000000102a91d12 libdispatch.dylib`_dispatch_worker_thread2 + 40
    frame #18: 0x0000000102deeef8 libsystem_pthread.dylib`_pthread_wqthread + 314
Adrian
  • 19,440
  • 34
  • 112
  • 219
  • Do you have an error in the [console](http://www.cimgf.com/wp-content/uploads/2012/12/Screenshot-121212-1219-AM.png)? – gitaarik Mar 27 '14 at 19:23
  • No error there, thats why I can't figure out what the problem is. – Adrian Mar 27 '14 at 19:26
  • What's going on in your main thread? Are you running anything in a `NSOperationQueue`? It looks like whatever is trying to run there is trying to access something that doesn't exist anymore (i.e. released). – SpacePyro Mar 27 '14 at 20:36
  • I just realizez I removed a picture from Supporting Files, but I haven't used it anymore. Now I rollback to my previous commit, before adding the PickerController, and give's me a build error regarding the missing picture: PBXCp error (the picture appears is red now in Supporting files). So I deleted the picture, and now every time it crashes. That could be the issue ? – Adrian Mar 27 '14 at 21:10
  • Can you post the code where you display the view/imagepicker? The simulator does not support camera mode and will cause a crash if you try to push an imagepicker in that mode. That being said, it normally tells you why it is crashing and isn't this ambiguous. Showing the expanded backtrace would help as well. – mrosales Mar 27 '14 at 21:34
  • as for the build issues, try cleaning the project and derived data folder as there could have been some issues with the build after you rolled back. – mrosales Mar 27 '14 at 21:34
  • @mros: I use only the code that I posted, which is commented out. I have also displayed the stack trace. – Adrian Mar 28 '14 at 05:56
  • From the stack trace it looks like the crash is happening in a completion block of the `[GPPSignIn checkSDKVersion]` call in an nslog statement where its trying to access a deallocated instance. It may be that the error is unrelated to the actual image picker. Try going through your handlers for sign in and check to see if there is any reason that there would be a deallocated instance there. – mrosales Mar 28 '14 at 14:27
  • you can also follow the advice in the top answer of this question: http://stackoverflow.com/questions/7940198/exc-bad-access-message-sent-to-deallocated-instance-but-im-using-arc to diagnose cause of the bad-access message – mrosales Mar 28 '14 at 14:27
  • Looks like everything was fixed by upgrading to 1.5.1, so I think your right about the checkSDKVersion method, it crashes while trying to say that a new version was available. If you can provide an answer for this, I will accept it – Adrian Mar 29 '14 at 11:38
  • IBOutlets should be nonatomic, weak (not retain) – CW0007007 Apr 01 '14 at 12:33

1 Answers1

1

As you can see in the backtrace it is a bug related with google+ SDK:

frame #7: 0x0000000100057726 SocialApp`__28-[GPPSignIn checkSDKVersion]_block_invoke + 439

I had exactly the same error using the version 1.5.0 of the SDK. Google just released v1.5.1 that fix that crash.

David Cordero
  • 770
  • 6
  • 16