0

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"];
Mike Abdullah
  • 14,933
  • 2
  • 50
  • 75
veereev
  • 2,650
  • 4
  • 27
  • 40
  • http://stackoverflow.com/questions/9182981/loading-a-plist-file-from-url please see this link...hope it helps – BhavikKama Sep 18 '13 at 07:42

3 Answers3

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

Refer this file handler utility which provides API's to interact with most of your file related operations.

It exposed API for below features,

  • Check if the file, or directory, exists in the given path
  • Create a folder in a given path
  • Verify if a folder exists at a given path
  • Get the size of a file
  • Check if a file with that name exists in the folder
  • Check if this folder has more subfolder or if it's the last folder

File Handler Utility Class link

thatzprem
  • 4,697
  • 1
  • 33
  • 41
-1

You can simply use the following method.

NSString *path = [[NSBundle mainBundle] pathForResource:@"a" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
manujmv
  • 6,450
  • 1
  • 22
  • 35