Link to home
Start Free TrialLog in
Avatar of Philippe Renaud
Philippe RenaudFlag for Canada

asked on

How to read a PLIST

Hi, please have a quick look here :

http://developer.apple.com/library/ios/#samplecode/TableViewUpdates/Introduction/Intro.html

in that source code, apple has a PLIST called PlaysAndQuotations

I have created a new plist within that same project and called it Test

I have changed the name of the argument in appDelegate where they create the NSUrl to go read the plist to Test

and nothing shows up (even if I have the same content of PlaysAndQuotations)   how come ?? ..
Avatar of darbid73
darbid73
Flag of Germany image

This bit right?

    NSURL *url = [[NSBundle mainBundle] URLForResource:@"PlaysAndQuotations" withExtension:@"plist"];

    NSArray *playDictionariesArray = [[NSArray alloc ] initWithContentsOfURL:url];

    NSMutableArray *playsArray = [NSMutableArray arrayWithCapacity:[playDictionariesArray count]];

Open in new window


It sounds to me like you have a small typing error somewhere.  If everything is like you say, step through your code and make sure that "url" in in fact an object, that you get a dictionaryobject with "playDictionariesArray " and you have a NSMutableArray with "playsArray"
Avatar of Philippe Renaud

ASKER

What I meant is that it works fine If I run it but as soon as I create a new PLIST with another name and I change that line :

NSURL *url = [[NSBundle mainBundle] URLForResource:@"PlaysAndQuotations" withExtension:@"plist"];


to :

NSURL *url = [[NSBundle mainBundle] URLForResource:@"Test" withExtension:@"plist"];


now I  see nothing in the TableView...  its the same url except a new name..  can u try ?
can you please follow what I said above with your "Test".  I think you are just making a simple mistake and stepping through the code will help to identify the problem.
When I step after    NSArray *playDictionariesArray = [[NSArray alloc ] initWithContentsOfURL:url];

playDictionariesArray is <nil>

looks like it does not find my PList in resources. But im not blind... it is in Resources... I see it in my project navigator
ASKER CERTIFIED SOLUTION
Avatar of darbid73
darbid73
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, yes it worked, very strange that with a new list i have problem but anyway .. thanks.


by the way, new question here regarding same subject :

https://www.experts-exchange.com/questions/27395019/how-do-have-multi-level-in-Table-View.html