Skip to content

Instantly share code, notes, and snippets.

View jfricker's full-sized avatar

John Fricker jfricker

View GitHub Profile
@jfricker
jfricker / gist:1358501
Created November 11, 2011 16:50
Common addition to PCH files
#ifdef DEBUG
#define DebugLog(...) NSLog(__VA_ARGS__)
#else
#define DebugLog(...) /* */
#endif
#define TraceLog(...) NSLog(__VA_ARGS__)
Charles Golvin, an analyst specializing in mobile technology at Forrester Research, said in an e-
mail message that the impact of Mr. Jobs’s departure might not be felt for 1.5 to 2 years, “given
that the next wave of products is far along in development and his continued presence as chairman.”
He added: “I think the key question is whether the Apple team will continue to work as effectively
as a collaborative without the single person to rely on for the final decision.”
// External Monitor with View Controller
// add this to you App Delegate subclass
// In applicationDidFinishLaunching ...
if ([UIScreen screens].count > 1) {
[self attachViewToExt];
}
//
/* example usage */
JFFollowRedirect* follower = [[JFFollowRedirect alloc] init];
[follower addObserver:self forKeyPath:@"redirectStr" options:NSKeyValueObservingOptionNew
context:follower];
// follow redirect
[follower getRedirectURLStr:urlToFollow];
/ * header */
#import <Foundation/Foundation.h>
//
// JFDataCache.h
//
#import <Foundation/Foundation.h>
@interface JFDataCache : NSObject {
NSMutableDictionary *cache;
}
//
// JFDataCache.m
//
#import "JFDataCache.h"
@implementation JFDataCache
-(id)init {
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
{
NSURL *loadURL = [ [ request URL ] retain ]; // retain the loadURL for use
if (([[loadURL scheme] isEqualToString: @"http"] ||
[[loadURL scheme] isEqualToString: @"https"] ) &&
(navigationType == UIWebViewNavigationTypeLinkClicked)) // Check if the scheme is http/https. You can also use these for custom links to open parts of your application.
return ![[UIApplication sharedApplication] openURL:[loadURL autorelease]]; // Auto release the loadurl because we wont get to release later. then return the opposite of openURL, so if safari cant open the url, open it in the UIWebView.
[loadURL release];
return YES; // URL is not http/https and should open in UIWebView
}
//
// AsyncImageView.h
//
#import <UIKit/UIKit.h>
@class JFDataCache;
@interface AsyncCachedImageView : UIView {
//could instead be a subclass of UIImageView instead of UIView, depending on what other features you want to
//
// AsyncImageView.m
//
#import "AsyncCachedImageView.h"
#import "JFDataCache.h"
@implementation AsyncCachedImageView
- (id)initWithFrame:(CGRect)frame {