Reputation: 3234
Currently I'm saving bookmarks in NSMutableIndexSet
- (BOOL)saveBookmark
{
if (!bookmarkIndex) {
bookmarkIndex = [NSMutableIndexSet indexSet];
}
if (currentIndex) {
[bookmarkIndex addIndex:currentIndex];
return [bookmarkIndex containsIndex:currentIndex];
}
return NO;
}
But when I exit the app and come back to check on bookmarks, the bookmarks are not showing then.
So thinking of storing bookmarks in NSUserDefaults
.
Is it possible to store NSMutableIndexSet
in NSUserDefaults
or only NSMutableArray
can be saved in NSUserDefaults
.
Is there is any example of storing NSMutableIndexSet
in NSUserDefaults
?
Appreciate help.
Thanks
Upvotes: 0
Views: 367
Reputation: 11112
In NSUserDefaults
all you can store are property lists. Read more about them here:
As you can see, you cannot store a NSIndexSet
in a property list, so you will need to use either a NSArray
or a NSDictionary
. I do not see any reason why cannot you store an array.
See the answer below on how to get indexes into an array:
Upvotes: 1