Take the 2-minute tour ×

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?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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].

share|improve this answer

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:

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...)

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.

share|improve this answer

Your Answer


