Skip to main content

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


Comments

  1. 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"]];

    ReplyDelete
  2. 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

    ReplyDelete

Post a Comment

Popular posts from this blog

Wildcards in a hosts file

I want to setup my local development machine so that any requests for *.local are redirected to localhost . The idea is that as I develop multiple sites, I can just add vhosts to Apache called site1.local , site2.local etc, and have them all resolve to localhost , while Apache serves a different site accordingly.