Graphics Programs Reference
In-Depth Information
Fast Enumeration
Before Objective-C 2.0, we iterated through arrays the way you did in your main function:
for (int i = 0; i < [items count]; i++) {
BNRItem *item = [items objectAtIndex:i];
NSLog(@"%@", item);
}
Objective-C 2.0 introduced fast enumeration . With fast enumeration, you can write that
code segment much more succinctly. Make the following change in main.m :
for (int i = 0; i < [items count]; i++) {
BNRItem *item = [items objectAtIndex:i];
NSLog(@"%@", item);
}
for (BNRItem *item in items) {
NSLog(@"%@", item);
}
items = nil;
In this chapter, we have covered the basics of Objective-C. In the next chapter, we will dis-
cuss memory management in Cocoa Touch.
 
Search WWH ::




Custom Search