I am tring to create an image using the NSData collected from Bluetooth. The data is saved in NSData variable recdata which is then converted to image using imageWithData. I am trying to save this image to the Photo library using the code below. But I don't see the image in the photo library. Am I missing something??
Also, as I am doing this project where I am receiving the data from bluetooth, I don't know how to check the error message on my iPhone screen. Currently, I am using the [information setText:[NSString stringWithFormat:@"%@", error.localizedFailureReason ]]; from the completionhandler to print the error message. But nothing gets printed and the app crashes and closes down.
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
//PHAssetResourceType assetType = PHAssetResourceTypePhoto;
UIImage *image = [UIImage imageWithData:recdata];
[PHAssetChangeRequest creationRequestForAssetFromImage: image];
[information setText:[NSString stringWithFormat:@"Krishna"]];
//PHAssetCreationRequest *request = [PHAssetCreationRequest creationRequestForAssetFromImage: image];
//PHAssetResourceCreationOptions *creationOptions = nil;
//creationOptions.originalFilename = command1; // Name of the file to be taken from command1
//[request addResourceWithType:assetType data:rxdata options:creationOptions]; //rxdata has all the data needed for the file to be transferred to the final image file.
} completionHandler:^(BOOL success, NSError *error) {
[information setText:[NSString stringWithFormat:@"%@", error.localizedFailureReason ]];
}];