Reputation: 1490
I have found couple of similar topic about this but none of them solve my problem. basically I want to read nsstring from my array in plist and then I want to overwrite the nsstring value.
NSArray *directoriespaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDir = [directoriespaths objectAtIndex:0];
NSString *fullnamefordir = [documentsDir stringByAppendingPathComponent:@"data.plist"];
NSArray *turns = [NSArray arrayWithContentsOfFile:fullnamefordir];
NSString *resultofarray = [turns objectAtIndex:0];
NSLog(@"%@",turns);
NSLog(@"%@",resultofarray);
nslog always shows null and i'm not trying to save anything so far because i can't even read the value :/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<string>8</string>
</array>
</plist>
i also tried with nsdictionary but it also doesn't work thanks in advance :)
Upvotes: 0
Views: 240
Reputation: 226
First Check whether your plist file exist in Document Directory or not.
NSFileMangaer *objFileManager=[[NSFileManager alloc]init];
BOOL isfileExist=[objFileManager fileExistsAtPath:yourDocumentDirectoryPath];
IF Bool Value is true then check you content of plist. May be the file doesnt exist in document directory ,it is in resource. If you didnot copied you plist from resource folder to document directory then first copy it there and then try to access it.
Upvotes: 3