[英]EXC_BAD_ACCESS on retriving NSData
在我的应用程序中,我使用相机和照片库获取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
}
}
您不是在访问属性,而是在访问属性后面的变量。 如果希望数据由属性自动保留,请使用属性设置器,例如self.imageData = ...
而不是imageData = ...
尝试
self.imageData = UIImageJPEGRepresentation(image.image,1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.