Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 11 characters in body
Source Link
Quinn Taylor
  • 44.8k
  • 16
  • 116
  • 135

Fast enumeration was added in 10.5 and in the iPhone OS, and it's significantly faster, not just syntactic sugar. If you have to target the older runtime (i.e. 10.4 and backwards), you'll have to use the old method of enumerating:

NSDictionary *myDict = ... some keys and values ... NSEnumerator *keyEnum = [myDict keyEnumerator]; id key; while ((key = [keyEnum nextObject])) { id value = [myDict objectForKey:key]; ... do work with "value" ... } 

Fast enumeration was added in 10.5 and in the iPhone OS. It's a little more than just syntactic sugar. You don't release the enumerator object, and you can't reset it. If you want to start over, you have to ask for a new enumerator object from the dictionary.

If you have to target the older runtime (i.e. 10.4 and backwards), you'll have to use the old method of enumerating:

NSDictionary *myDict = ... some keys and values ... NSEnumerator *keyEnum = [myDict keyEnumerator]; id key; while ((key = [keyEnum nextObject])) { id value = [myDict objectForKey:key]; ... do work with "value" ... } 

Fast enumeration was added in 10.5 and in the iPhone OS. It's a little more than just syntactic sugar. You don't release the enumerator object, and you can't reset it. If you want to start over, you have to ask for a new enumerator object from the dictionary.

Fast enumeration was added in 10.5 and in the iPhone OS, and it's significantly faster, not just syntactic sugar. If you have to target the older runtime (i.e. 10.4 and backwards), you'll have to use the old method of enumerating:

NSDictionary *myDict = ... some keys and values ... NSEnumerator *keyEnum = [myDict keyEnumerator]; id key; while ((key = [keyEnum nextObject])) { id value = [myDict objectForKey:key]; ... do work with "value" ... } 

You don't release the enumerator object, and you can't reset it. If you want to start over, you have to ask for a new enumerator object from the dictionary.

Source Link
dreamlax
  • 95.7k
  • 31
  • 166
  • 211

If you have to target the older runtime (i.e. 10.4 and backwards), you'll have to use the old method of enumerating:

NSDictionary *myDict = ... some keys and values ... NSEnumerator *keyEnum = [myDict keyEnumerator]; id key; while ((key = [keyEnum nextObject])) { id value = [myDict objectForKey:key]; ... do work with "value" ... } 

Fast enumeration was added in 10.5 and in the iPhone OS. It's a little more than just syntactic sugar. You don't release the enumerator object, and you can't reset it. If you want to start over, you have to ask for a new enumerator object from the dictionary.