Skip to content

Instantly share code, notes, and snippets.

View carbamide's full-sized avatar

Josh Barrow carbamide

  • Oklahoma
View GitHub Profile
@carbamide
carbamide / gist:5057702
Created February 28, 2013 15:49
Split a long string into an array with a given max number of characters
+(NSArray *)splitString:(NSString *)str maxCharacters:(NSInteger)maxLength
{
NSMutableArray *tempArray = [NSMutableArray arrayWithCapacity:1];
NSArray *wordArray = [str componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSInteger numberOfWords = [wordArray count];
NSInteger index = 0;
NSInteger lengthOfNextWord = 0;
while (index < numberOfWords) {
@carbamide
carbamide / AgeOfJosh.m
Created January 17, 2014 15:57
Age of Josh command line Foundation app
#import <Foundation/Foundation.h>
int ageOfJosh(int realAge)
{
int statedAge = 29;
if (realAge > 29) {
return statedAge;
}
@carbamide
carbamide / gist:8962667
Last active August 29, 2015 13:56
Random name
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
NSArray *names = @[@"Jones", @"Carvin", @"Cuckler", @"Davis", @"Etchison", @"Gable", @"Barrow"];
int nameIndex = arc4random_uniform([names count]);
NSLog(@"%@", names[nameIndex]);
}
if ((![phoneNumber isEqualToString:[NSString string]]) && phoneNumber) {
// phone number exists
}
else if (([phoneNumber isEqualToString:[NSString string]]) && phoneNumber) {
phoneNumber = [user phone];
}