i am trying to extract a property of an instance of a class that is a property of another class! easier shown by example...
// Person is a class with properties: name and age
Person *person = [[Person alloc] init];
[person setName:@"Alex"];
// Age is a class with properties value (i.e. 100) and unit (i.e. year)
Age *age = [[Age alloc] init];
[age setValue:@100];
[person setAge:age];
NSMutableArray *people = [[NSMutableArray alloc] init];
[people addObject:person];
for (id person in people) {
how can i extract the value property of the age instance associated to the person?
//[person valueForKey:@"age.value")];
i expect to get @100 - i get 'NSInvalidArgumentException'
this gives me the instance of Age - but i would rather have the value property.
//[person valueForKey:@"age")];
}
is this possible? any help is much appreciated.
Aucun commentaire:
Enregistrer un commentaire