ObjC - neo-anderson/Notes GitHub Wiki

Numbers, Formatting, Conversions
http://stackoverflow.com/questions/2573611/converting-nsdecimalnumber-to-nsstring
http://stackoverflow.com/questions/2985170/format-string-integer-with-leading-zeros
http://stackoverflow.com/questions/4793181/how-to-increment-a-nsnumber
http://stackoverflow.com/questions/4358987/objective-c-convert-number-to-nsnumber
http://stackoverflow.com/questions/6634244/can-not-assign-a-float-to-nsnumber http://stackoverflow.com/questions/20373785/how-to-divide-nsdecimalnumber-by-integer
http://stackoverflow.com/questions/15409437/nsuinteger-being-less-than-0-why

Strings
http://stackoverflow.com/questions/1612337/objective-c-best-way-to-extract-substring-from-nsstring
http://stackoverflow.com/questions/19464261/xctassertequal-fails-to-compare-two-string-values

Checking if a string is numeric or not
http://stackoverflow.com/questions/11588571/ios-how-do-i-check-if-a-string-is-numeric-or-not
http://stackoverflow.com/questions/1320295/check-that-a-input-to-uitextfield-is-numeric-only
http://stackoverflow.com/questions/6091414/finding-out-whether-a-string-is-numeric-or-not

NSScanner *scanner = [NSScanner scannerWithString:testString];
BOOL isNumeric = [scanner scanInteger:NULL] && [scanner isAtEnd];
NSCharacterSet* notDigits = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
if ([newString rangeOfCharacterFromSet:notDigits].location == NSNotFound)
{
    // newString consists only of the digits 0 through 9
}
BOOL valid;
NSCharacterSet *alphaNums = [NSCharacterSet decimalDigitCharacterSet];
NSCharacterSet *inStringSet = [NSCharacterSet characterSetWithCharactersInString:myInputField.text];
valid = [alphaNums isSupersetOfSet:inStringSet];    
if (!valid) // Not numeric

Declaring constants
Integer? Just add like this -

#define var_name 2

String? Declare as static constants -

static NSString* const var_name @"String";

http://stackoverflow.com/questions/1937685/static-nsstring-usage-vs-inline-nsstring-constants
http://stackoverflow.com/questions/2092005/when-to-use-static-string-vs-define
http://stackoverflow.com/questions/18283988/ios-define-or-static-const-for-global-strings