Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Garn andrewgarn

View GitHub Profile
@andrewgarn
andrewgarn / gist:4698826
Last active Dec 12, 2015
Checking for iOS update on app store
View gist:4698826
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 Jul 24, 2012
Skip backup NSURL category for iOS.
View NSDate+AGCategory.h
//
// 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 Jul 23, 2012
Making NSDateFormatter thread safe
View NSDate+AGCategory.h
//
// 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
Macro for creating objective-c singleton with custom accessor that supports both arc (GCD) and non arc environments
View AGSynthesizeSingleton.h
//
// 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 Apr 18, 2012
GIT Ignore File for iOS Projects
View .gitignore
.DS_Store
*.swp
*~.nib
build/
*.pbxuser
*.perspective
*.perspectivev3
*.mode1v3
*.mode2v3
*.mode1
@andrewgarn
andrewgarn / XcodeScripts.sh
Created Apr 17, 2012
Xcode 4 Build Version Scripts
View XcodeScripts.sh
# 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