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 ?? ..
LVL 1
PhilippeRenaudAsked:
Who is Participating?
 
darbid73Connect With a Mentor Commented:
but "url" is an object right?

If url is an object then it sounds to me like there is something going on the with the format of the file...could that be.  I am not up with this.  To try to cancel out any problems, take Apples file that works, go to it in finder and copy that file.  Then rename it. Then add the newly named file to xcode.  Then amend it in xcode.
0
 
darbid73Commented:
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"
0
 
PhilippeRenaudAuthor Commented:
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 ?
0
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

 
darbid73Commented:
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.
0
 
PhilippeRenaudAuthor Commented:
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
0
 
PhilippeRenaudAuthor Commented:
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 :

http://www.experts-exchange.com/Apple/Programming/Q_27395019.html


0
All Courses

From novice to tech pro — start learning today.