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
| -(void)addContact{ | |
| ABRecordRef person; | |
| ABMultiValueRef social = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType); | |
| ABMultiValueAddValueAndLabel(social, [NSDictionary dictionaryWithObjectsAndKeys: | |
| (NSString *)kABPersonSocialProfileServiceTwitter, kABPersonSocialProfileServiceKey, | |
| @"justinbieber", kABPersonSocialProfileUsernameKey, | |
| nil], kABPersonSocialProfileServiceTwitter, NULL); | |
| ABRecordSetValue(person, kABPersonSocialProfileProperty, social, NULL); | |
| CFRelease(social); |
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
| Dear soon-to-be-former user, | |
| We've got some fantastic news! Well, it's great news for us anyway. You, on | |
| the other hand, are fucked. | |
| We've just been acquired by: | |
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 <dlfcn.h> | |
| #import <Foundation/Foundation.h> | |
| struct BlockDescriptor | |
| { | |
| unsigned long reserved; | |
| unsigned long size; | |
| void *rest[1]; |
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
| - (void)loadDefaultSettings | |
| { | |
| NSMutableDictionary *defaults = [NSMutableDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default-Settings" ofType:@"plist"]]; | |
| // other setup... | |
| [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithDictionary:defaults]]; | |
| } | |
| - (void)resetDefaultSettings |
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
| NSData *bom = nil; | |
| NSStringEncoding encoding = ...; | |
| NSData *a = [@"a" dataUsingEncoding:encoding]; | |
| NSData *aa = [@"aa" dataUsingEncoding:encoding]; | |
| if ([a length] * 2 != [aa length]) { | |
| NSUInteger characterLength = [aa length] - [a length]; | |
| bom = [a subdataWithRange:NSMakeRange(0, [a length]-characterLength)]; | |
| } |
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
| 1. Thou shalt always use Key Value Observing | |
| 2. Thou shalt not block the main thread | |
| 3. Thou shalt compile with zero errors or warnings | |
| 4. Thou shalt use #pragma mark to separate code into groups based on related functionality |
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
| // Usage example: | |
| // input image: http://f.cl.ly/items/3v0S3w2B3N0p3e0I082d/Image%202011.07.22%2011:29:25%20PM.png | |
| // | |
| // UIImage *buttonImage = [UIImage ipMaskedImageNamed:@"UIButtonBarAction.png" color:[UIColor redColor]]; | |
| // .h | |
| @interface UIImage (IPImageUtils) | |
| + (UIImage *)ipMaskedImageNamed:(NSString *)name color:(UIColor *)color; | |
| @end |
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
| #define blockSafe_cat(A, B) A##B | |
| #define blockSafe_line(V, TMP) typeof(V) blockSafe_cat(blockSafe_tmp__, TMP) = V; __block typeof(V) V = blockSafe_cat(blockSafe_tmp__, TMP) | |
| #define blockSafe(V) blockSafe_line(V, __LINE__) |
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
| #ifndef NDEBUG | |
| #define InfDebugLog( ... ) NSLog( __VA_ARGS__ ) | |
| #else | |
| #define InfDebugLog( ... ) | |
| #endif |
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
| #!/bin/sh | |
| RESULT=$(xcodebuild -configuration Debug RUN_CLANG_STATIC_ANALYZER=YES) | |
| if `echo ${RESULT} | grep "generated." 1>/dev/null 2>&1` | |
| then | |
| echo "commit failed: anaylzer error found" | |
| exit 1 | |
| fi |