Note that there are some explanatory texts on larger screens.

plurals
  1. POCopy plist to documents directory and read from it
    primarykey
    data
    text
    <p>I'm copying the plist to documents directory when didFinishLaunchingWithOptions in AppDelegate like this:</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self performSelector:@selector(copyPlist)]; return YES; } - (void)copyPlist { NSFileManager *fileManger=[NSFileManager defaultManager]; NSError *error; NSArray *pathsArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString *doumentDirectoryPath=[pathsArray objectAtIndex:0]; NSString *destinationPath= [doumentDirectoryPath stringByAppendingPathComponent:@"Obj.plist"]; if ([fileManger fileExistsAtPath:destinationPath]){ NSLog(@"database localtion %@",destinationPath); return; } NSString *sourcePath=[[[NSBundle mainBundle] resourcePath]stringByAppendingPathComponent:@"Obj.plist"]; [fileManger copyItemAtPath:sourcePath toPath:destinationPath error:&amp;error]; } </code></pre> <p>Then I'm trying to display the content of the plist in my views like this:</p> <pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Obj.plist"]; NSLog(@"plist path %@", path); sortedObj = [[NSMutableArray alloc]initWithContentsOfFile:path]; NSLog(@"objects %@", sortedObj); </code></pre> <hr> <p>LOG RESULTS:</p> <p>database localtion:</p> <pre><code>/Users/kdb/Library/Application Support/iPhone Simulator/5.1/Applications/4E165740-01CD-4ED3-8971-FDCCB1751DD1/Documents/Obj.plist </code></pre> <p>plist path:</p> <p>the same as database location</p> <p>objects:</p> <p>(null)</p> <p>The content is empty. How to make it work?</p> <p>The plist is an array with dictionaries.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload