Reputation: 9555
I have an array of integers stored in a plist. I would to load them and do fast enumeration over the array. Is there a way to do this or does fast enumeration work only for objects?
Upvotes: 0
Views: 818
Reputation: 11666
I do undestand OOP is nice but if You have an array of integers and You must scan values very often, consider storing value in a simple C array:
advantages:
1) much less memory footprint
2) blazing speed in searching (for via and index, a REAL index in memory.. will be a register in µp directly...)
disadvantages:
a) you must think in old style C
b) save the number of items
c) you must convert from plist to int arr[..] but is very easy.
Upvotes: 0
Reputation: 14672
Fast enumeration do only work with objects in Obj-C.
However, if you stored integer values in a plist, you'll have an NSArray
or an NSDictionary
instance representing that plist. The NSArray
/NSDictionary
works with fast enumeration and will output NSNumbers
when working with them, not int
.
That way, you can retrieve your int
easily with [anNSNumber intValue]
.
Upvotes: 3