Skip to content

Instantly share code, notes, and snippets.

@ronsims2
Created August 25, 2016 13:21
Show Gist options
  • Save ronsims2/8566b184525c176e95db9a8666d25ff7 to your computer and use it in GitHub Desktop.
Save ronsims2/8566b184525c176e95db9a8666d25ff7 to your computer and use it in GitHub Desktop.
Example of how to left pad in Objective-C
//
// main.m
// testcode
//
// Created by Ron Sims II on 6/6/16.
// Copyright © 2016 Ron Sims II. All rights reserved.
//
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSInteger foo = 142;
NSString *formattedFoo = [NSString stringWithFormat:[NSString stringWithFormat:@"STJ%%0%ddT1", 4], foo];
NSLog(@"Store Number: %@", formattedFoo);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment