If you do not want to use mutable arrays, and also do not want to repeat your identifier N times, use NSArray , which can be initialized from a C-style array:
@interface NSArray (Foo) + (NSArray*)arrayByRepeatingObject:(id)obj times:(NSUInteger)t; @end @implementation NSArray (Foo) + (NSArray*)arrayByRepeatingObject:(id)obj times:(NSUInteger)t { id arr[t]; for(NSUInteger i=0; i<t; ++i) arr[i] = obj; return [NSArray arrayWithObjects:arr count:t]; } @end // ... NSLog(@"%@", [NSArray arrayByRepeatingObject:@"SO" times:10]);
Georg Fritzsche
source share