I defined a NSArray in a header file like this:
@property (nonatomic, retain) NSArray *ages;
In my implementation I want to set this variable like this:
ages = [self setAges:[ageValues allKeys]];
‘ageValues’ is a NSDictionary. So what I do is just setting the array of keys to my self-defíned array. Strange enough, I get the following error message:
Asssigning to ‘NS Array *’ from incompatible type ‘void’
But where can I find something void here? In my opionion I am just setting another array ([ageValues allKeys) to my own array and I can’t find anything void???
The
setAges:method is a method that returnsvoid, in other words: it returns nothing (not evennilor something; it literally is not returning anything). Now you cannot assign “nothing” to a variable.That being said, your code wants to do the same thing twice. All you want to do is simply:
or:
They do exactly the same, but use different syntax (the compiler transforms the first into the second).