在我的應用程序中,我使用相機和照片庫來獲取UIImage ...挑選圖像後,我需要將其轉換爲NSData,並希望將此數據傳遞給名爲addBlobToContainer的方法:.. ..但它給了EXC_BAD_ACCESS .... 我該如何解決這個問題?EXC_BAD_ACCESS在檢索NSData
這裏是我的照片庫中的代碼...
- (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
}
}
向我們展示'imageData'的聲明。它是「強」還是「弱」? – Sulthan 2013-03-16 12:19:16
也是serviceURL和GUID的聲明。 – 2013-03-16 12:20:14
不要給你的標識符名稱,如「圖像」。使用適當的枚舉UIImagePickerControllerEditedImage不是你定義的字符串(這可能是問題?) – 7usam 2013-03-16 12:22:48