Hi,
I have a problem reading from my plist file. I have tried multiple methods and none are working. I am stuck on this for a long time. I have already seek countless helps and looked up for solutions. I don't know why is this taking too long for me to solve. So I need your help.
The last few lines are used because each time I want to assign the NSArray to the path location, I get 0x0 (nil). Below is the image of my plist.
I have a problem reading from my plist file. I have tried multiple methods and none are working. I am stuck on this for a long time. I have already seek countless helps and looked up for solutions. I don't know why is this taking too long for me to solve. So I need your help.
Code:
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //1
NSString *documentsDirectory = [paths objectAtIndex:0]; //2
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"EventAddress.plist"]; //3
NSLog(@"%@", path);
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath: path]) //4
{
NSString *bundle = [[NSBundle mainBundle] pathForResource:@"EventAddress" ofType:@"plist"]; // 5
[fileManager copyItemAtPath:bundle toPath: path error:&error]; //6
}
NSString *pathss = [[NSBundle mainBundle] bundlePath];
NSLog(@"%@", pathss);
NSArray* plist = [NSArray arrayWithContentsOfFile:path];
NSLog(@"%@", plist);
The last few lines are used because each time I want to assign the NSArray to the path location, I get 0x0 (nil). Below is the image of my plist.
