View ViewModelServices.m
This file contains 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
- (void)pushViewModel:(BaseViewModel *)nextViewModel | |
{ | |
NSString *from = [self standardNameFromViewModel:_currentViewController.viewModel]; | |
NSString *to = [self standardNameFromViewModel:nextViewModel]; | |
// We are going to try and find a segue to go to the next viewModel. The way segues are named | |
// in our storyboard should be: FromModel::ToModel | |
// 1. try Segue method. For example, a segue going from WelcomeViewController to LoginViewController would be named "Welcome::Login" | |
// 2. If a segue is not found, try to instantiate the view controller and push it directly. We look up the view controller by its stripped model name (i.e. "WelcomeViewModel" -> "Welcome") | |
// 3. If the view controller is not found in the storyboard, try a XIB with the stripped model name. |
View dispatch_once.m
This file contains 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
dispatch_once_t once; | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
dispatch_once(&once, ^{ | |
NSLog(@"one"); | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
once = 0; | |
dispatch_once(&once, ^{ | |
NSLog(@"two"); |
View RACSignal+FPOperations.h
This file contains 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
// | |
// Created by Florent Pillet on 30/01/15. | |
// | |
#import <Foundation/Foundation.h> | |
@interface RACSignal (FPOperations) | |
/// Delivers the receiver's latest `next`s with a minimum of `interval` | |
/// seconds between two values. Of `next` values produced by the receiver |
View gist:270266
This file contains 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
/* Base UIViewController subclass for your iPhone applications which automatically | |
* releases your instance variables pointing to UIView objects or UIView-subclassed objects, | |
* limiting the work you have to do in -dealloc and -viewDidUnload | |
* | |
* All you have to do is make your UIViewController subclasses inherit from BaseUIViewController | |
* instead of UIViewController | |
* | |
* The helper function that disposes of objects is generalized and can be used for other | |
* types of objects as well. | |
* |
View gist:717759
This file contains 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
// If you really want to do this without using a set, you can do it this way | |
NSUInteger count = [marray count]; | |
for (NSUInteger i = 0; i < (count-1); i++) { | |
[marray removeObjectIdenticalTo:[marray objectAtIndex:i] inRange:NSMakeRange(i+1, count-i-1); | |
count = [marray count]; | |
} |
View NSLoggerMacros.h
This file contains 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 macros that you can leave in production code, and turn on a flag to activate logging | |
#import "LoggerClient.h" | |
extern BOOL gLoggingEnabled; | |
#define LOG_APP(...) if (gLoggingEnabled) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"app", ##__VA_ARGS__); else do {} while(0) | |
#define LOG_CACHE(...) if (gLoggingEnabled) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"cache", ##__VA_ARGS__); else do {} while(0) | |
#define LOG_XML_PARSING(...) if (gLoggingEnabled) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"xml", ##__VA_ARGS__); else do {} while(0) | |
#define LOG_SOUNDS(...) if (gLoggingEnabled) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"sounds", ##__VA_ARGS__); else do {} while(0) |
View NSManagedObjectContext+FP.m
This file contains 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
- (void)logDetailedError:(NSError *)error from:(id)caller selector:(SEL)selector | |
{ | |
#if DEBUG | |
LogMessage(@"coredata", 0, @"*** CORE DATA ERROR: a data store operation failed"); | |
LogMessage(@"coredata", 0, @"*** Caller was: %@ %p %@", [caller class], caller, NSStringFromSelector(selector)); | |
LogMessage(@"coredata", 0, @"*** Error: %@", [error localizedDescription]); | |
NSArray* detailedErrors = [[error userInfo] objectForKey:NSDetailedErrorsKey]; | |
if ([detailedErrors count] > 0) | |
{ | |
for(NSError* detailedError in detailedErrors) |
View gist:1034444
This file contains 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
//Setup join arrays for used joins monitoring and clearing | |
for (var join in gui.allJoins) { | |
joinType = gui.allJoins[join].charCodeAt(0); | |
joinNumber = parseInt(gui.allJoins[join].substr(1)); | |
if ((joinType == 0x64) && (joinNumber >= self.DJoin_Low) && (joinNumber <= self.DJoin_High) && (joinNumber != self.DJoin_connectedFB) && (!self.PageJoins[gui.allJoins[join]])) { //digital | |
self.DJoins.push(gui.allJoins[join]); | |
self.ClearJoins.push({join:gui.allJoins[join], value:0}); | |
} else if ((joinType == 0x61) && (joinNumber >= self.AJoin_Low) && (joinNumber <= self.AJoin_High)) { //analog | |
self.AJoins.push(gui.allJoins[join]); |
View MyBuffer.js
This file contains 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
var MyModule = { | |
var self = { | |
buffer : "", | |
defaultSize : 20, | |
carriageReturn : "99" | |
}, | |
setup : function() { | |
// we could remove this function if there is nothing to do | |
}, |
View OrderedRequestQueue.js
This file contains 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
/* OrderedRequestQueue.js | |
* | |
* Push CF.request calls using this object instead of directly using CF.request, and | |
* you'll be guaranteed to receive results in the order you pushed them. Note that this | |
* implies that the queue will BLOCK until each result is received in sequence, which may | |
* cause large delays if one site in the list is long to respond. | |
* | |
* Use at your own risk | |
*/ | |
var OrderedRequestQueue = (function(){ |
OlderNewer