This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ViewController.h" | |
#import "FoursquareAuthentication.h" | |
@interface ViewController () | |
@end | |
@implementation ViewController | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - Web view delegate | |
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { | |
if([request.URL.scheme isEqualToString:@"ios-app"]){ | |
// 8. get the url and check for the access token in the callback url | |
NSString *URLString = [[request URL] absoluteString]; | |
if ([URLString rangeOfString:@"access_token="].location != NSNotFound) { | |
// 9. Store the access token in the user defaults | |
NSString *accessToken = [[URLString componentsSeparatedByString:@"="] lastObject]; | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "FoursquareAuthentication.h" | |
// 5. setup some helpers so we don't have to hard-code everything | |
#define FOURSQUARE_AUTHENTICATE_URL @"https://foursquare.com/oauth2/authorize" | |
#define FOURSQUARE_CLIENT_ID @"YOUR CLIENT ID" | |
#define FOURSQUARE_CLIENT_SECRET @"YOUR CLIENT SECRET" | |
#define FOURSQUARE_REDIRECT_URI @"ios-app://redirect" | |
@interface FoursquareAuthentication () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@class WineUtils; | |
static int const COMPONENTS_IN_REGION = 2; | |
static int const COMPONENTS_DEFAULT = 1; | |
typedef enum ChooserUIEnum{ | |
CTYear, | |
CTRegion, | |
CTType |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@class ChooserViewController; | |
static int const HIGHEST_RATING = 5; | |
static int const LOWEST_RATING = 1; | |
static int const CHOOSER_VIEW = 5000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int const CURRENT_YEAR = 2013; | |
static int const MAX_YEARS = 20; | |
@interface WineUtils : NSObject | |
@property(nonatomic, strong) NSDictionary *wineRegionsDict; | |
@property (nonatomic, strong) NSArray *wineTypes; | |
@property (nonatomic, strong) NSArray *wineYears; | |
- (NSArray *)wineRegionsForCountry:(NSString *)country; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When using setTimeout, use one of the following patterns | |
//ex1 | |
var fn1 = function(){ | |
// do something | |
}; | |
setTimeout(fn1, 0); | |
//ex2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// End each statement with a semicolon | |
// example 1 - var that is assigned to a function | |
var foo = function(){ | |
// do some stuff | |
}; // semicolon required to end statement | |
// Example 2 - no semicolon needed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example 1: Wrapping function and passing in global variables | |
// self-executing function that passes in the global context via this when the file loads | |
(function myGlobalExample(global){ | |
return { | |
testFn: function(){ | |
var doIt = global.doItTimes(5); | |
return doIt; | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//uses the following syntax to create an object with private properties | |
// and functions. You expose the properties and functions you need publicly in the | |
// return object.... The immediate function allows us to have private scope for | |
// certain things | |
// Create a new namespace | |
CHATHAM.namespace('CHATHAM.utils.gridmgr'); | |
CHATHAM.utils.gridmgr = (function(){ |
NewerOlder