Skip to content

Instantly share code, notes, and snippets.

View ArchieGoodwin's full-sized avatar
🏠
Working from home

Sergey Dikarev ArchieGoodwin

🏠
Working from home
View GitHub Profile
@ArchieGoodwin
ArchieGoodwin / gist:10102852
Created April 8, 2014 08:56
URL encode in iOS >= 7.0
[string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
@ArchieGoodwin
ArchieGoodwin / gist:9615906
Created March 18, 2014 08:37
Singleton declaration
@interface
+(id)sharedInstance;
@implementation
- (id)init {
self = [super init];
#if !(TARGET_IPHONE_SIMULATOR)
@ArchieGoodwin
ArchieGoodwin / gist:9614019
Created March 18, 2014 05:25
Correct realisation of didUpdateToLocations and get locality
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *newLocation = locations.lastObject;
NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow];
if (locationAge > 5.0) return;
if (newLocation.horizontalAccuracy < 0) return;
// Needed to filter cached and too old locations