[Objective-c NSArray] 사용법
Objective-C & OpenGL ES 2009. 7. 25. 15:10 |## Style1
NSArray* array = [NSArray arrayWithObjects:object1, object2, object3 nil];
NSEnumerator* enumerator = [array objectEnumerator];
NSString* aString = @"son";
id anObject = [enumerator nextObject];
while (anObject != nil)
{
[anObject doSomethingWithString:aString];
anObject = [enumerator nextObject];
}
## Style2
NSArray* array = [NSArray arrayWithObjects:object1, object2, object3 nil];
NSEnumerator* enumerator = [array objectEnumerator];
NSString* aString = @"son";
id anObject = nil;
while ((anObject = [enumerator nextObject]))
{
[anObject doSomethingWithString:aString];
}
##Style3
NSArray* array = ''';
for(id object in someContainer)
{
...
}