Skip to content

Instantly share code, notes, and snippets.

@basecode
Created July 18, 2012 19:19
Show Gist options
  • Save basecode/3138231 to your computer and use it in GitHub Desktop.
Save basecode/3138231 to your computer and use it in GitHub Desktop.
NSArray+Additions
// NSArray+Additions.h
// Copyright (c) 2012 Tobias Reiss (MIT License)
#import <Foundation/Foundation.h>
@interface NSArray (Additions)
+ (id)arrayWithObject:(id)object count:(NSUInteger)cnt;
@end
// NSArray+Additions.m
// Copyright (c) 2012 Tobias Reiss (MIT License)
#import "NSArray+Additions.h"
@implementation NSArray (Additions)
// see http://stackoverflow.com/a/7979198/705888
+ (id)arrayWithObject:(id)object count:(NSUInteger)cnt
{
id objects[cnt];
for (int i = 0; i < cnt; ++i) {
objects[i] = object;
}
return [NSArray arrayWithObjects:objects count:cnt];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment