gpt4 book ai didi

iphone - 检索 NSData 时的 EXC_BAD_ACCESS

转载 作者:行者123 更新时间:2023-11-28 19:11:04 25 4
gpt4 key购买 nike

在我的应用程序中,我使用相机和照片库来获取 UIImage...选择图像后,我需要将其转换为 NSData 并希望将此数据传递给名为 addBlobToContainer 的方法:....但是它给出 EXC_BAD_ACCESS....我该如何解决这个问题?

这是我的照片库代码...

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
image.image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
imageData = [NSData dataWithData:UIImageJPEGRepresentation(image.image,1)];
guid = [Guid randomGuid];
NSLog(@"%@", guid.description);
GUID = guid.description;
NSLog(@"GUID===%@",GUID);
[self dismissViewControllerAnimated:YES completion:nil];
}

-(void)viewWillAppear:(BOOL)animated
{
NSLog(@"STRIMAGEDATA===%@",imageData);

if ([imageData length] != 0)
{
NSLog(@"%@",imageData);
[client addBlobToContainer:newcontainer blobName:GUID contentData:imageData contentType:@"application/octet-stream" withBlock:^(NSError *error)
{
if (error)
{
NSLog(@"%@",[error localizedDescription]);
}
else
{
NSLog(@"blob inserted suuccessfully…");
imageURL = [serviceURL stringByAppendingString:[NSString stringWithFormat:@"%@.jpg",GUID]];
NSLog(@"IMAGEURL=%@",imageURL);
}
}];-->EXC_BAD_ACCESS
}
}

最佳答案

您不是在访问属性,而是在访问属性背后的变量。如果您希望属性自动保留数据,请使用属性 setter ,例如self.imageData = ... 而不是 imageData = ...

关于iphone - 检索 NSData 时的 EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15448973/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com