NSData *sourceData = [[NSData alloc]initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Information" ofType:@"plist"]];
NSString *sourceString = [[NSString alloc]initWithData:sourceData encoding:NSUTF8StringEncoding];
Yields an empty string (and yes, NSData
is loaded correctly).
From here: https://stackoverflow.com/a/6412275/555690, it says that I need to use the correct encoding.
When I go to Information.plist
and check the source code, it begins with
<?xml version="1.0" encoding="UTF-8"?>
So, as far as I'm concerned, I'm indeed using the right encoding. What is the problem then?
Note
I'm not really trying to read the contents of Information.plist
(I know I can do this by doing something like dictionaryWithContentsOfFile
etc etc) - I am just curious about converting its corresponding NSData
to an NSString
.