Search code examples
iosnsbundle

How to access files at a path NSURL


Hello everyone i have the following code :

  NSString* issuePath =[[self contentURL] URLByAppendingPathComponent:@"magazine"].path;

I have a file called a.plist in the above directory. I have to read the a.plist file contents. How to do that. Before the file was local and I was accessing it as follows

 NSString *path = [[NSBundle mainBundle] pathForResource:@"a" ofType:@"plist"];

Solution

  •   NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0]; 
        NSString *path = [documentsDirectory stringByAppendingPathComponent:@"a.plist"];       
    NSMutableDictionary *plistContents = [[NSMutableDictionary alloc] initWithContentsOfFile:path];