Skip to content

Instantly share code, notes, and snippets.

@atg
Created March 5, 2013 21:44
Show Gist options
  • Save atg/5094579 to your computer and use it in GitHub Desktop.
Save atg/5094579 to your computer and use it in GitHub Desktop.
print 'static NSString* formatWithArguments(NSString* fmt, NSArray* args) {'
print ' switch ([args length]) {'
print ' case 0:'
print ' return [NSString stringWithFormat:fmt];'
for n in xrange(1, 127):
print ' case %d:' % n
print ' return [NSString stringWithFormat:fmt, %s];' % ', '.join('args[%d]' % i for i in xrange(n))
print ' default:'
print ' return nil;'
print ' }'
print '}\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment