NSMutableArray alloc and init not working properly
-
28-05-2021 - |
Question
I've been coding for a while now but seem to be getting this issue regularly which never occurred before. When trying to init arrays / dictionaries they always show as empty even though I'm sure they are being initialised correctly.
This is simply an NSMutableArray which I @property (nonatomic, retain) and @synthesize. Can anyone tell me why this would be happening as I've noticed it happening in places where it wasn't before. Could this simply be the prediction/intellisense displaying incorrect information, and if so how can I fix it?
Thanks in advanced, Elliott
Solution
Try to type po self.pickerObjects
in console (and Enter). Xcode may not show actual info sometimes. You code looks good, i think it's just an Xcode glitch).
OTHER TIPS
Yes I have noticed something like that. NSLog
pickerObjects, and see what happens.
NSLog(@"%@", self.pickerObjects);
if i'm not mistaken..this is because you have your array as class property instead of instance variable
remove @property and @synthesize and call it as pickerObjects = [........]
to use self.pickerObjects you first need to alloc and init your view (what you're doing there is calling a class property..and you haven't inited your class)
(does that make sence?)
i'm not very good with explaining...but this is the problem..try that and see what happens