我有一个带有按钮的 NIB 文件。当我单击此按钮时,将调用 setWallpaper: 选择器。一切都按预期工作(图像已保存),除了 malloc 引发的错误。
malloc: *** error for object 0x184d000: pointer being freed was not allocated ***
set a breakpoint in malloc_error_break to debug
我在 malloc_error_break 处设置了一个断点,但我对调试器一无所知。我什至找不到对象 0x184d000。有谁知道为什么会这样?在将 UIImage 发送到 UIImageWriteToSavedPhotosAlbum 之前,我也曾尝试保留它,但没有成功。
我的代码如下:
- (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];
}