How can I pass a "MutableArray
with full of Objects" to another class by using NSUserDefaults
? I know how to pass "MutableArray
"s but this does not work!
So;
I have a MutableArray; 'myCityObjects
', and I populate it with objects; 'cities
'
In each 'cities
' object there are properties like cityName
, cityLocation
etc...
[myCityObjects addObject:cities];
Now, what I want to do is to pass this MutableArray
(filled with objects) to another class by using 'NSUserDefaults
';
[[NSUserDefaults standardUserDefaults] setObject: myCityObjects forKey:@"MCO"];
And in the other class,
NSMutableArray *getMyCityObjects = [[NSArray alloc] init];
getMyCityObjects = [[NSUserDefaults standardUserDefaults] mutableArrayValueForKey:@"MCO"];
But it doesn't work! I cannot get myCityObjects
in the other class, "getMyCityObjects
" is empty. How can I fix that?
Thanks, E.