I have implemented the logic of writing files into document directory.
NSData *pngData = UIImagePNGRepresentation([UIImage imageNamed:@"logo_icon_login.png"]);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"image.png"];
if ([[NSFileManager defaultManager] isWritableFileAtPath:filePath])
{
[pngData writeToFile:filePath atomically:YES];
}
else
{
NSLog(@"Not writable.");
}
Now the problem is in some devices it says Not writable. Is there any permission should I need before writing files in the documents directory?