I have an NIB file with a button. When I click this button, the setWallpaper: selector is called. Everything works as expected (the image is saved), excepte by the error thrown by malloc.
malloc: *** error for object 0x184d000: pointer being freed was not allocated ***
set a breakpoint in malloc_error_break to debug
I've set a breakpoint at malloc_error_break, but I don't understand anything from the debugger. I couldn't even find the object 0x184d000. Does anyone know why is this happening? I had also tried to retain the UIImage before sending it to UIImageWriteToSavedPhotosAlbum, but without success.
My code is below:
- (IBAction)setWallpaper:(id)sender {
UIImage *image = [UIImage imageNamed:@"wallpaper_01.png"];
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:NSLocalizedString(@"Galo!!!",@"Saved image message: title")
message:NSLocalizedString(@"Now, check your \"saved photos\" group at \"photos\" app in your iPhone and select the actions menu > set as wallpaper.",@"Saved image message")
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK",@"OK Button")
otherButtonTitles:nil];
[alertView show];
[alertView release];
}