«зависимости» не могут применяться к «(groovy.lang.Closure)»

Вам нужно сохранить только путь внутри DocumentDirectory (имя каталога / файла) и добавить его в DocumentDirectory каждый раз при загрузке файла ...

-(void)saveImage:(UIImage *)image{
NSData *pngData = UIImagePNGRepresentation(image);
NSString *pathInDocumentDirectory = [APP_DocumentDirectory stringByAppendingPathComponent:PROFILE_IMAGE_NAME];
NSString *filePath = [self documentsPathForFileName:pathInDocumentDirectory];
//Save pic file path - DirName/Filename.png
[XYZPreferencesHelper setUserImageFilePath:pathInDocumentDirectory];
 //Write the file
[[NSFileManager defaultManager] createFileAtPath:filePath contents:pngData attributes:nil];

}



-(void)loadSavedUserPicture{
//Load saved DirName/Filename.png
NSString *pathInDocumentDirectory = [XYZPreferencesHelper getUserImageFilePath];

if (pathInDocumentDirectory != nil){
    //Full path with new app Document Directory
    NSString *filePath = [self documentsPathForFileName:pathInDocumentDirectory];
    if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]){
        NSData *pngData = [NSData dataWithContentsOfFile:filePath];
        UIImage *image = [UIImage imageWithData:pngData];
        if (image != nil){
            userPicImageView.image = image;
        }

    }

 }
}



- (NSString *)documentsPathForFileName:(NSString *)name
{
NSString *documentsPath = [self createRestcallDirectoryIfNotExist];
return [documentsPath stringByAppendingPathComponent:name];
}



-(NSString *)createRestcallDirectoryIfNotExist{
NSString *path;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
path = [documentsPath stringByAppendingPathComponent:APP_DocumentDirectory];
NSError *error;
if (![[NSFileManager defaultManager] fileExistsAtPath:path])    //Does directory already exist?
{
    if (![[NSFileManager defaultManager] createDirectoryAtPath:path
                                   withIntermediateDirectories:NO
                                                    attributes:nil
                                                         error:&error])
    {
        NSLog(@"Create directory error: %@", error);
    }
}
return documentsPath;
}
118
задан Sufian 23 December 2015 в 07:01
поделиться