halloway4b
halloway4b

Reputation: 573

Read plist from URL into NSMutableDictionary

I am trying to do read a PLIST from URL to a NSMutableDictionary.

Code before

autos = [[NSMutableArray alloc] init];

[autos addObject:[[NSMutableDictionary alloc]initWithObjectsAndKeys:@"Auto 1", @"name", @"Auto.png", @"image", @"Klassiker", @"description" , nil]];

This works. But now I want to use a PLIST. And I am trying this, this way:

autos = [[NSMutableArray alloc]initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://dl.dropbox.com/u/9358444/auto.plist"]]];

Thanks.

PLIST http://dl.dropbox.com/u/9358444/auto.plist

Upvotes: 1

Views: 1819

Answers (2)

DdD
DdD

Reputation: 453

I'm new to the site, I'm still not sure how to add comments to the OP. Load it into a dictionary first then transfer it into a mutable array

Upvotes: 0

Caleb
Caleb

Reputation: 125007

Your property list contains a dictionary, but you're trying to use it to instantiate an array. Do this instead:

NSMutableDictionary *autos = [[NSMutableDictionary alloc] initWithContentsOfURL:
                                 [NSURL urlWithString:@"http://dl.dropbox.com/u/9358444/auto.plist"]];

Upvotes: 1

Related Questions