Skip to content

Instantly share code, notes, and snippets.

@shannoga
shannoga / simplepastiefile.m
Created May 30, 2011 12:41
Get only numbers from NSString
+(NSString*)getOnlyNumbersFromString:(NSString*)stringToStrip{
NSMutableString *strippedString = [NSMutableString
stringWithCapacity:stringToStrip.length];
NSScanner *scanner = [NSScanner scannerWithString:stringToStrip];
NSCharacterSet *numbers = [NSCharacterSet
characterSetWithCharactersInString:@"0123456789"];
while ([scanner isAtEnd] == NO) {
NSString *buffer;
@mombrea
mombrea / iOS-UploadImage.h
Created January 17, 2014 01:49
example of a multi-part form post in objective-c
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"REST URL PATH"]];
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[request setHTTPShouldHandleCookies:NO];
[request setTimeoutInterval:60];
[request setHTTPMethod:@"POST"];
NSString *boundary = @"unique-consistent-string";
@brennanMKE
brennanMKE / printKeychainResultCode.swift
Last active October 26, 2022 10:19
Print Keychain Result Code which is an OSStatus used with various services such as Keychain
// MARK: - Internal -
internal func printResultCode(resultCode: OSStatus) {
// See: https://www.osstatus.com/
switch resultCode {
case errSecSuccess:
print("Keychain Status: No error.")
case errSecUnimplemented:
print("Keychain Status: Function or operation not implemented.")