Hi,
-(NSString *)restorePhoto:(NSString *)param param1:(NSString *)param1
param2:(NSString *)param2{
__block BOOL bResult = NO;
__block NSString *sFilePath = @"";
NSString *sAppDocPath = [[[[NSFileManager defaultManager]
URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]
path];
sAppDocPath = [sAppDocPath stringByAppendingPathComponent: @"cn1storage"];
NSString *sTmpFilePath = [sAppDocPath stringByAppendingPathComponent:
param];
NSData *data = [[NSFileManager defaultManager] contentsAtPath:
sTmpFilePath];
__block NSConditionLock * albumReadLock = [[[NSConditionLock alloc]
initWithCondition:WDASSETURL_PENDINGREADS] retain];
ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc]init];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
0), ^{
[assetsLibrary saveImageData: data
toAlbum: param2
metadata: nil
completion: ^(NSURL *assetURL, NSError *error) {
if (error) {
bResult = NO;
} else {
bResult = YES;
//sFilePath = [NSString
stringWithString:[assetURL absoluteString]];
//sFilePath = [[assetURL absoluteString] copy];
sFilePath = [[NSString alloc]
initWithString:[assetURL absoluteString]];
}
[albumReadLock lock];
[albumReadLock
unlockWithCondition:WDASSETURL_ALLFINISHED];
}
failure: ^(NSError *error) {
NSLog(@"[restorePhoto] There is an error: %@", error);
[albumReadLock lock];
[albumReadLock
unlockWithCondition:WDASSETURL_ALLFINISHED];
}
];
/*
[assetsLibrary writeImageDataToSavedPhotosAlbum:data metadata:nil
completionBlock:^(NSURL *assetURL, NSError *error) {
if (error) {
bResult = NO;
} else {
bResult = YES;
}
[albumReadLock lock];
[albumReadLock unlockWithCondition:WDASSETURL_ALLFINISHED];
}
];
*/
});
[albumReadLock lockWhenCondition:WDASSETURL_ALLFINISHED];
[albumReadLock unlock];
[albumReadLock release];
[assetsLibrary release];
//[sFilePath autorelease];
NSLog(sFilePath);
return sFilePath;
}
It is the native function we called then the string return. We can sure the
"sFilePath" value is exist before return. Then it goes cn1 library code till
the error as previous post.
For your reference, the three strings params
1. param : tmp{datetime}_{filename e.g. IMG_123.JPG}
2. param1 : {filename}
3. param2 : "Camera Roll"
Please help to find out the solution. I would appreciated if the problem could
be solved in a few days.
Thanks and Regards,
On Saturday, August 27, 2016 at 1:53:34 PM UTC+8, Shai Almog wrote:
>
> The error isn't here. It's before this point as str is corrupted by the
> time you reached this code.
>
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/f23197ce-3a72-4500-bc51-1a4985c2a012%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.