更多见
#import <Foundation/Foundation.h> |
#import "Photo.h" |
int main ( int argc, const char * argv[]) |
{ |
NSAutoreleasePool * pool = [[ NSAutoreleasePool alloc] init]; |
NSDictionary *dict = [ NSDictionary dictionaryWithObjectsAndKeys: |
[[Photo alloc] init], @ "p1" , |
[[Photo alloc] init], @ "p2" , |
[[Photo alloc] init], @ "p3" , nil ]; |
|
//for...in 只能遍历NSDictionary的Key |
NSString *key; |
for (key in dict) |
{ |
[[dict objectForKey:key] draw]; |
} |
|
//如果要遍历对象,需要通过objectEnumerator进行转换 |
for ( id obj in [dict objectEnumerator]) |
{ |
[obj draw]; |
} |
|
[pool drain]; |
return 0; |
} |