Store an array of UIViews in NSUserDefaults

Posted by Mona on Stack Overflow See other posts from Stack Overflow or by Mona
Published on 2012-10-26T22:23:17Z Indexed on 2012/10/26 23:00 UTC
Read the original article Hit count: 206

Filed under:
|
|
|
|

I'm trying to add an array of uiviews to NSDefault but it doesn't seem to be keep the array. Does any one know why? I also tried to store each view in nsvalue before storing it in nsdefault which still didn't work.

NSArray *arr = [[NSArray alloc] initWithObjects:[NSValue valueWithNonretainedObject:myView], nil]];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:arr forKey:@"myKey"];

NSArray *resultArray = [defaults objectForKey:@"myKey"];

and resultArray is nil!

Thanks

the reason why I'm trying to do this is because these are the header views of my uitableview. Since it takes time to create them I wanted to create them only once and store them for future access.

© Stack Overflow or respective owner

Related posts about ios

Related posts about arrays