Skip to content

Instantly share code, notes, and snippets.

View RandyMcMillan's full-sized avatar
🛰️
Those who know - do not speak of it.

@RandyMcMillan RandyMcMillan

🛰️
Those who know - do not speak of it.
View GitHub Profile
@RandyMcMillan
RandyMcMillan / gist:2381583
Created April 14, 2012 02:13
iOS3 / iOS4 / iOS5 threshold switch
NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
BOOL isLessThaniOS4 = ([systemVersion compare:@"4.0" options:NSNumericSearch] == NSOrderedAscending);
BOOL isGreaterThaniOS4 = ([systemVersion compare:@"4.0" options:NSNumericSearch] == NSOrderedDescending);
BOOL isLessThaniOS5 = ([systemVersion compare:@"5.0" options:NSNumericSearch] == NSOrderedAscending);
BOOL isGreaterThaniOS5 = ([systemVersion compare:@"5.0" options:NSNumericSearch] == NSOrderedDescending);
if (isLessThaniOS4 && isLessThaniOS5)
{
//NSLog(@"isLessThaniOS4 && isLessThaniOS5 = %@",whatever);
}
@RandyMcMillan
RandyMcMillan / gist:2409856
Created April 17, 2012 23:26
.gitignore everything but .gitignore
# Ignore everything in this directory
*
# Except this file
!.gitignore
@RandyMcMillan
RandyMcMillan / gist:2562430
Created April 30, 2012 20:30
Detect iOS systemVersion and Retina Display
+ (NSString*) resolveImageResource:(NSString*)resource
{
NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
BOOL isLessThaniOS4 = ([systemVersion compare:@"4.0" options:NSNumericSearch] == NSOrderedAscending);
// the iPad image (nor retina) differentiation code was not in 3.x, and we have to explicitly set the path
if (isLessThaniOS4)
{
return [NSString stringWithFormat:@"%@.png", resource];
@RandyMcMillan
RandyMcMillan / openInSafari.m
Created May 20, 2012 16:18
MainViewController.m (openInSafari) switch
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
{
NSURL *requestURL =[ [ request URL ] retain ];
if ( ( [ [ requestURL scheme ] isEqualToString: @"http" ] || [ [ requestURL scheme ] isEqualToString: @"https" ] || [ [ requestURL scheme ] isEqualToString: @"mailto" ])
&& ( /*navigationType == UIWebViewNavigationTypeLinkClicked ||*/ navigationType == UIWebViewNavigationTypeOther ) ) {
return ![ [ UIApplication sharedApplication ] openURL: [ requestURL autorelease ] ];
}
[ requestURL release ];
return YES;
}
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
/*
if (IS_IPAD) {}
else
if (!IS_IPAD) {}
else {}
*/
@RandyMcMillan
RandyMcMillan / shouldAutorotateToInterfaceOrientation.m
Created June 10, 2012 01:08
iOS shouldAutorotateToInterfaceOrientation
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
// Return YES for supported orientations
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight){
return YES;
}
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft){
return YES;
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
//NSLog(@"RECIEVED MEM WARNING WHY?");
[self report_memory];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
}
-(void) report_memory {
//#import "mach/mach.h" ///Add to headers
@RandyMcMillan
RandyMcMillan / IS_IPAD_with_statusBarOrientation.m
Created June 30, 2012 15:04
IS_IPAD and statusBarOrientation support
//#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
if ([[UIApplication sharedApplication] statusBarOrientation] < 3) {//portrait
if (IS_IPAD) {
} else {
@RandyMcMillan
RandyMcMillan / my.cfg
Created September 5, 2012 05:22
my.cfg uncrustify config file
# Uncrustify 0.59
#
# General options
#
# The type of line endings
newlines = auto # auto/lf/crlf/cr
# The original size of tabs in the input
@RandyMcMillan
RandyMcMillan / version.sh
Created October 12, 2012 21:19 — forked from osteslag/version.sh
Script for managing build and version numbers using git and agvtool. See link in comments below.
#!/bin/sh
# Script for managing build and version numbers using git and agvtool.
# Change log:
# v1.0 18-Jul-11 First public release.
# v1.1 29-Sep-12 Launch git, agvtool via xcrun.
version() {