I have a picture in the application loaded into the UIImageView via the URL . Tell me, please, how to make it so that it is nested in the program? Those. kept in the program itself.

    1 answer 1

    In what format do you want to store the picture in jpeg or png ? For both there is a save option.

     // Путь для хранения ваших файлов. NSString *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/картинка.png"]; NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/картинка.jpg"]; // качество сжатия для картинки диапазон от 0.0-1.0 // создаем файл ЖПГ [UIImageJPEGRepresentation(image, 1.0) writeToFile:jpgPath atomically:YES]; // создаем файл ПНГ [UIImagePNGRepresentation(image) writeToFile:pngPath atomically:YES]; NSError *error; NSFileManager *fileMgr = [NSFileManager defaultManager]; NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; NSLog(@"Documents directory: %@", [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]); 

    PS image is your picture from the Internet.

    • > [NSHomeDirectory () stringByAppendingPathComponent: @ "Documents / picture.png"] The question is not very clear, but maybe @ Sergey4590 meant that the picture was originally stored in the program? - VioLet
    • Well, as if it is stored there, then why save it? Well, then you need to clarify where it is stored, in NSBundle or on the server, or in some application directory? - x86-64
    • @ x86-64 and the topstarter never says that he needs to save something . - VioLet
    • Oh well, do not start, the man asked how to keep it, I answered. Any more complaints? - x86-64
    • one
      @ x86-64 :) Yes, I do not carp, I just could not understand the wording of the question itself. PS I apologize, read the title of the question. The brain itself already filters seemingly "unnecessary data". - VioLet