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
MyObject *one = [[MyObject alloc] init]; | |
one.message = @"Hello World!"; | |
one.intValue = 1; | |
MyObject *two = [MyObject objectFromArchive:[one archivedObject]]; | |
NSLog(@"Retrieved Message: %@", two.message); | |
NSLog(@"Should be 0, but is 1: %d", two.intValue); | |
@interface MyObject : SMXObject |
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> | |
#import <complex.h> | |
@interface JuliaOperation : NSOperation | |
@property (nonatomic, readwrite, assign) NSUInteger width; | |
@property (nonatomic, readwrite, assign) NSUInteger height; | |
@property (nonatomic, readwrite, assign) complex long double c; | |
@property (nonatomic, readwrite, assign) complex long double blowup; | |
@property (nonatomic, readwrite, assign) CGFloat contentScaleFactor; | |
@property (nonatomic, readwrite, assign) NSUInteger rScale; |
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
#!/usr/bin/python | |
# fix-xcode | |
# Rob Napier <[email protected]> | |
# Script to link in all your old SDKs every time you upgrade Xcode | |
# Create a directory called /SDKs (or modify source_path). | |
# Under it, put all the platform directories: | |
# MacOSX.platform iPhoneOS.platform iPhoneSimulator.platform | |
# Under those, store the SDKs: |
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
all: test | |
testa: source.o libA.a libB.a | |
g++ source.cpp -o test libA.a libB.a | |
testb: | |
g++ source.cpp -o test libB.a libA.a | |
libA.a: a.o aprime.o | |
ar -r libA.a a.o aprime.o |
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
// Main thread priorty = 0.758065 | |
NSLog(@"main:%@:%f", [NSThread currentThread], [NSThread threadPriority]); | |
// High priority = 0.532258 | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ | |
NSLog(@"high:%@:%f", [NSThread currentThread], [NSThread threadPriority]); | |
// run forever! Note that other queues still happily process, even though our high-priority block never ends | |
while(1) {} | |
}); |
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
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
struct Stuff { | |
int x; | |
int y; | |
}; | |
int x; | |
struct Stuff s; | |
printf("%d:%d\n", x, s.y); |
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, const char * argv[]) | |
{ | |
@autoreleasepool { | |
for(NSUInteger i = 0; i < 10000; i++) | |
{ | |
for(NSUInteger j = 0; j < 10000; j++) | |
{ | |
NSNumber* n = [NSNumber numberWithUnsignedInteger:j]; |
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 for http://stackoverflow.com/questions/21699184/resource-leak-or-not-mac-os-x | |
#import <CoreServices/CoreServices.h> | |
#import <SystemConfiguration/SCDynamicStore.h> | |
#import <SystemConfiguration/SCDynamicStoreCopySpecific.h> | |
#include <iostream> | |
#include <thread> | |
void Execute() | |
{ |
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
// With dot syntax (and standard Xcode indentation, just hit "Cmd-I") | |
NSArray *tweets = Underscore.array(results) | |
.filter(Underscore.isDictionary) | |
.reject(^BOOL (NSDictionary *tweet) { | |
return [tweet[@"iso_language_code"] isEqualToString:@"en"]; | |
}) | |
.map(^NSString *(NSDictionary *tweet) { | |
NSString *name = tweet[@"from_user_name"]; | |
NSString *text = tweet[@"text"]; |
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
func dispatch_sync<R> (queue: dispatch_queue_t, block: Void -> R ) -> R { | |
var result: R! | |
dispatch_sync(queue) { | |
result = block() | |
} | |
return result | |
} | |
func result() -> String { | |
return |
OlderNewer