Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

App crashes when downloading image from URL

morandsmorands Posts: 18Registered Users
edited May 2012 in iPhone SDK Development
Hi guys,
I need to save an image from a URL and to do that I use this piece of code (found here)
-(IBAction)saveImage:(id)sender {

NSURL *frontViewURL = [NSURL URLWithString:indirizzo];
NSData *frontViewData = [NSData dataWithContentsOfURL:frontViewURL];
UIImage *frontViewAlert = [UIImage imageWithData:frontViewData];
UIImageWriteToSavedPhotosAlbum(frontViewAlert, self, @selector(frontView:didFinishSavingWithError:contextInfo:), self);
}


But when I put the button, after successfully saving the photo in the camera roll, the app crash and I got tis log:
2012-05-20 11:16:05.460 SpectttatorTest-iOS[16813:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSInvocation invocationWithMethodSignature:]: method signature argument cannot be nil'
*** First throw call stack:
(0x33f068bf 0x341561e5 0x33e6406f 0x3576dd91 0x3576e5db 0x3576c7d5 0x36b2fd55 0x36b3ae8d 0x33ed92dd 0x33e5c4dd 0x33e5c3a5 0x306e0fcd 0x372dd743 0x2219 0x21a4)
terminate called throwing an exception(lldb)


I'd like to hear if you've any idea about why ut happened and how I could fix it.

Thanks in advance
Post edited by morands on

Replies

  • WarblrWarblr Posts: 164Registered Users
    edited May 2012
    I don't know anything about NSInvocation, but as far as I can tell from the docs it is a mac OSX object (not iOS).

    Availability :
    Available in Mac OS X v10.0 and later.
    In any case, this...

    2012-05-20 11:16:05.460 SpectttatorTest-iOS[16813:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSInvocation invocationWithMethodSignature:]: method signature argument cannot be nil'
    ...is your issue (aside from the fact that you may be trying to run a Mac OSX only object/method on an iOS platform). Are you calling invocationWithMethodSignature anywhere?
  • morandsmorands Posts: 18Registered Users
    edited May 2012
    Warblr;432860 said:
    I don't know anything about NSInvocation, but as far as I can tell from the docs it is a mac OSX object (not iOS).


    In any case, this...

    ...is your issue (aside from the fact that you may be trying to run a Mac OSX only object/method on an iOS platform). Are you calling invocationWithMethodSignature anywhere?
    Thanks for your reply.
    I'm definitely not calling invocationWithMethodSignature anywhere and what surprise me the most is that actually it works and save the photo to camera roll!
  • WarblrWarblr Posts: 164Registered Users
    edited May 2012
    I see.

    What method is being called here:

    But when I put the button, after successfully saving the photo in the camera roll...
  • morandsmorands Posts: 18Registered Users
    edited May 2012
    Oh, looks like I finally came to a solution. I changed completely the code but now works... here's the new:

    -(IBAction)saveImage:(id)sender {

    UIImage *shot = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]];

    // Save image
    UIImageWriteToSavedPhotosAlbum(shot, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
    }

    - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
    {
    UIAlertView *alert;

    // Unable to save the image
    if (error)
    alert = [[UIAlertView alloc] initWithTitle:@\"Error\"
    message:@\"Not saved.\"
    delegate:self cancelButtonTitle:@\"Ok\"
    otherButtonTitles:nil];
    else // All is well
    alert = [[UIAlertView alloc] initWithTitle:@\"Success\"
    message:@\"Saved\"
    delegate:self cancelButtonTitle:@\"Ok\"
    otherButtonTitles:nil];
    [alert show];
    [alert release];
    }

    I hope this will be useful to somebody.


    Thanks, Warblr for your time. :)
Sign In or Register to comment.