Skip to content

Instantly share code, notes, and snippets.

View andrewgarn's full-sized avatar

Andrew Garn andrewgarn

View GitHub Profile
@andrewgarn
andrewgarn / gist:4698826
Last active December 12, 2015 02:28
Checking for iOS update on app store
NSString *requestPath = [NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@", @"528968746"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:requestPath]];
AFJSONRequestOperation *operation = [[AFJSONRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSArray *results = [responseObject objectForKey:@"results"];
if (results && [results isKindOfClass:[NSArray class]] && [results count] > 0) {
NSString *resultVersion = [[results objectAtIndex:0] objectForKey:@"version"];
NSString *installedVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
if ([installedVersion compare:resultVersion options:NSNumericSearch] == NSOrderedAscending) {
@andrewgarn
andrewgarn / NSDate+AGCategory.h
Created July 24, 2012 14:24
Skip backup NSURL category for iOS.
//
// NSURL+AGCategory.m
// AGFoundation
//
// Created by Andrew Garn on 24/07/2012.
// Copyright (c) 2012 Andrew Garn. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@andrewgarn
andrewgarn / NSDate+AGCategory.h
Created July 23, 2012 15:24
Making NSDateFormatter thread safe
//
// NSDate+AGCategory.h
// AGFoundation
//
// Created by Andrew Garn on 23/07/2012.
// Copyright (c) 2012 Andrew Garn. All rights reserved.
//
#import <Foundation/Foundation.h>
@andrewgarn
andrewgarn / AGSynthesizeSingleton.h
Created May 4, 2012 08:53
Macro for creating objective-c singleton with custom accessor that supports both arc (GCD) and non arc environments
//
// AGSynthesizeSingleton.h
// Agnomical SDK
//
// Created by Andrew Garn on 22/03/2012.
// Copyright (c) 2012 Andrew Garn. All rights reserved.
//
/**
Singleton interface method macro
@andrewgarn
andrewgarn / .gitignore
Created April 18, 2012 11:25
GIT Ignore File for iOS Projects
.DS_Store
*.swp
*~.nib
build/
*.pbxuser
*.perspective
*.perspectivev3
*.mode1v3
*.mode2v3
*.mode1
@andrewgarn
andrewgarn / XcodeScripts.sh
Created April 17, 2012 13:58
Xcode 4 Build Version Scripts
# Run script to increase CFBundleVersion by 1 each time a build is archived under release or adhoc
#!/bin/sh
if [ "$CONFIGURATION" == Adhoc || "$CONFIGURATION" == Release ]; then
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
fi
# Run script to set CFBundleVersion to local latest git commit hash