Friday, 9 January 2015

iOS-Copy from NSBUndle TO NSDocumentDirectory



Here is a code snippet  to Copy file from NSBUndle To NSDocumentDirectory


NSError *error;

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *path = [documentsDirectory stringByAppendingPathComponent:@"data.plist"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath: path])

{

NSString *bundle = [[NSBundle mainBundle] pathForResource:@”data” ofType:@”plist”];
[fileManager copyItemAtPath:bundle toPath: path error:&error];

}

1 comment:

  1. Excellent post on iOS mobile apps development!!! The future of mobile application development is on positive note. You can make most it by having in-depth knowledge on mobile application development platform and other stunning features. IOS Course in Chennai

    ReplyDelete