Skip to content

Instantly share code, notes, and snippets.

ipedro / gcd_thread.m
Last active Mar 23, 2016
GCD background thread
View gcd_thread.m
// get off main thread and execute costly code
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
// jump back to main thread and update your UI
dispatch_async(dispatch_get_main_queue(), ^{
ipedro /
Created Mar 18, 2016 — forked from mbinna/
Clear CocoaPods cache, re-download and re-install all pods
#!/usr/bin/env bash
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
ipedro / makeCountriesJSON.m
Last active Jan 8, 2016
extract country display names in different languages
View makeCountriesJSON.m
NSArray<NSString*> *localeIds = @[@"pt", @"en"];
NSArray<NSString*> *countryCodesArray = [NSLocale ISOCountryCodes];
NSMutableString *json = [NSMutableString stringWithString:@"{"];
[localeIds enumerateObjectsUsingBlock:^(NSString * localeId, NSUInteger localeIndex, BOOL * _Nonnull stop) {
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:localeId];
ipedro / Objective-C String Sanitation
Created Nov 13, 2014
Removes accents, spaces, tabs and punctionation from a given string
View Objective-C String Sanitation
+(NSString*)sanitizeString:(NSString *)originalString
// example string
// NSString *unfilteredString = @"!@#$%^&*()_+|abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
// define the characters you want to allow
NSString *allowedChars =@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
// makes an inverted set based on your setting
NSCharacterSet *notAllowedChars = [[NSCharacterSet characterSetWithCharactersInString:allowedChars] invertedSet];
You can’t perform that action at this time.