Pregunta

I am new to xCode and I am trying to display the values inside my property list in a table view, but I can only show the key values. Here is my code so far, what should I tip to display the values? I have tried like 10 example codes already and still doesn't get it. Thx for any help =)

familiaEspecie is a NSDictionary, and especie is a NSMutableArray

NSBundle *bundle = [NSBundle mainBundle];
NSURL *plistURL = [bundle URLForResource:@"Animales"
                           withExtension:@"plist"]; 
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:plistURL];
self.familiaEspecie = dictionary;
especie=[[familiaEspecie allKeys]sortedArrayUsingSelector:@selector(compare:)];
¿Fue útil?

Solución

[familiaEspecie allValues]; should fetch you all the values in the dictionary.

If you want to retrieve the values after the sorting (based on how your keys have been sorted), you could iterate and get each value like this:

for (NSString *key in especie)
{
  id value = [self.familiaEspecie valueForKey:key];
  // Do whatever with 'value'
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top