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
+ (NSManagedObject *)managedObjectFromStructure:(NSDictionary *)structureDictionary | |
entityName:(NSString *)entityName | |
withManagedObjectContext:(NSManagedObjectContext *)context { | |
NSMutableDictionary *mutableStructureDictionary = [structureDictionary mutableCopy]; | |
NSManagedObject *managedObject = [NSEntityDescription insertNewObjectForEntityForName:entityName | |
inManagedObjectContext:context]; | |
NSDictionary *relationshipsByName = [[managedObject entity] relationshipsByName]; |
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
+ (NSManagedObject *)managedObjectFromStructure:(NSDictionary *)structureDictionary | |
entityName:(NSString *)entityName | |
withManagedObjectContext:(NSManagedObjectContext *)context { | |
NSMutableDictionary *mutableStructureDictionary = [structureDictionary mutableCopy]; | |
NSManagedObject *managedObject = nil; | |
NSManagedObjectModel *model = [context.persistentStoreCoordinator managedObjectModel]; | |
for (NSString *property in [mutableStructureDictionary allKeys]) { |
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
+ (NSInvocation *)invocationWithTarget:(id)target action:(SEL)selector arguments:(NSArray *)arguments retainArguments:(BOOL)retainArguments { | |
NSMethodSignature *signature = nil; | |
if (isClass(target)) { | |
signature = [target methodSignatureForSelector:selector]; | |
} else { | |
signature = [[target class] instanceMethodSignatureForSelector:selector]; | |
} | |
NSInvocation *invocation = [self invocationWithMethodSignature:signature]; |
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
//UIColor+Defined.h | |
typedef uint32_t DColor; | |
+ (UIColor *)colorWithDefinedColor:(DColor)dColor; | |
+ (UIColor *)colorWithDefinedColor:(DColor)dColor alpha:(CGFloat)alpha; | |
//UIColor+Defined.m | |
+ (UIColor *)colorWithDefinedColor:(DColor)dColor { | |
return [self colorWithDefinedColor:dColor alpha:1.0f]; | |
} |
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_semaphore_t semaphore = dispatch_semaphore_create(1); | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
sleep(1); | |
dispatch_semaphore_signal(semaphore); | |
sleep(1); | |
dispatch_semaphore_signal(semaphore); | |
sleep(1); | |
dispatch_semaphore_signal(semaphore); | |
}); |
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
#import <Foundation/Foundation.h> | |
int main(int argc, char *argv[]) { | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
dispatch_semaphore_t semaphore = dispatch_semaphore_create(1); | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void) { | |
sleep(1); | |
dispatch_semaphore_signal(semaphore); | |
}); |
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
/*jslint undef: true, nomen: true, eqeqeq: true, plusplus: true, newcap: true, immed: true, browser: true, devel: true, passfail: false */ | |
/*global window: false, readConvertLinksToFootnotes: false, readStyle: false, readSize: false, readMargin: false, Typekit: false, ActiveXObject: false */ | |
var dbg = (typeof console !== 'undefined') ? function(s) { | |
console.log("Readability: " + s); | |
} : function() {}; | |
/* | |
* Readability. An Arc90 Lab Experiment. | |
* Website: http://lab.arc90.com/experiments/readability |
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
- Copy the delivered ipa into a directory to work in. | |
- export PlistBuddy="/usr/libexec/PlistBuddy" to get the PlistBuddy tool to your shell. If it is not added, all references to PlistBuddy | |
will need to be written as the full path. | |
- Take the delivered App.ipa and unzip it using the unzip command. This should produce a Payload directory containing the app and its | |
resources. | |
- Enter the command "codesign -d --entitlements :enterprise.plist Payload/PathToApp.app/" This pulls the entitlements out of the app, and | |
prints them to a plist, without a leading "blob" of data. Pay particular attention to the colon before the enterprise.plist file name. |
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
#include <objc/runtime.h> | |
#include <objc/message.h> | |
+ (void)printClassMethods:(Class)class { | |
NSLog(@"Methods in %@", NSStringFromClass(class)); | |
unsigned int out_count = 0; | |
Method *class_methods = class_copyMethodList(class, &out_count); | |
for (int i = 0; i < out_count; i++) { | |
Method m = class_methods[i]; | |
NSLog(@"\t%@", NSStringFromSelector(method_getDescription(m)->name)); |
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 performAnimation(UIView *view, CGFloat angle, CGFloat targetAngle); | |
void performAnimation(UIView *view, CGFloat angle, CGFloat targetAngle) { | |
[UIView animateWithDuration:1 delay:0 options:UIViewAnimationCurveEaseOut animations:^(void) { | |
[view setTransform:CGAffineTransformMakeRotation(angle)]; | |
} completion:^(BOOL finished) { | |
if (targetAngle > M_PI_4) { | |
performAnimation(view, angle + M_PI_4, targetAngle - M_PI_4); | |
} else | |
if (targetAngle > 0) { | |
performAnimation(view, targetAngle, 0); |
OlderNewer