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
@interface MyClass : NSObject | |
@end | |
@implementation MyClass | |
+ (void)myMethod | |
{ | |
NSArray *x = [[self alloc] init]; // This _doesn't_ throw a warning, despite +alloc and -init both being declared as instancetype |
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
@interface Person | |
// Derived from JSON | |
@property (readonly) NSString *personID; | |
@property (readonly) NSString *name; | |
… | |
@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
/* | |
My goal here is to have an immutable model class with an initialiser that is hidden unless you import a private header ("Person+Private.h"). This is useful in the context of providing a library or framework where consuming code only ever has read-only access to instances of this class, and they are never supposed to create instances themselves. | |
*/ | |
… | |
//*********************************** | |
// Person.h | |
// |
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
// Apple LLVM - Warnings - All languages | |
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES | |
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES | |
CLANG_WARN_EMPTY_BODY = YES | |
GCC_WARN_SHADOW = YES | |
CLANG_WARN_CONSTANT_CONVERSION = YES | |
GCC_WARN_64_TO_32_BIT_CONVERSION = YES | |
CLANG_WARN_ENUM_CONVERSION = YES | |
CLANG_WARN_INT_CONVERSION = YES | |
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES |
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
sudo tmutil delete "`tmutil listbackups | sed -n 1p`" |
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
NSString *jsonString = @"{\"myNumber\":1029742590268606522}"; | |
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; | |
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:NULL]; | |
NSLog(@"jsonDict: %@", jsonDict); | |
uint64_t myNumber = [jsonDict[@"myNumber"] unsignedLongLongValue]; | |
NSLog(@"myNumber: %llu", myNumber); | |
/* |
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)someCallbackWithAViewController:(UIViewController *)viewController | |
{ | |
if ([viewController conformsToProtocol:@protocol(CrazyViewController)]) | |
{ | |
UIViewController <CrazyViewController> *crazyVC = (UIViewController <CrazyViewController> *)viewController; | |
if (crazyVC.presentedViewController == nil) | |
{ | |
[crazyVC showCrazyModalView]; | |
} | |
else |
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
# Homebrew path config | |
export PATH="$PATH:/usr/local/bin:/usr/local/sbin" | |
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib" | |
export CPATH="$CPATH:/usr/local/include" |
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
# Change this: | |
... | |
#!/usr/bin/ruby | |
require 'osx/cocoa' | |
# My Script… |
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
// KVC Compile-time Helpers | |
// | |
// These macros allow simple compile-time checking of KVC keypaths, as long as the getter methods for properties | |
// match up with their property names (i.e. if the property 'available' has the getter method 'isAvailable', these | |
// macros will break) | |
#define Key(class, key) (0 ? ((class *)nil).key, (NSString *)nil : @#key) | |
#define InstanceKey(instance, key) (0 ? ((__typeof(instance))nil).key, (NSString *)nil : @#key) | |
#define SelfKey(key) (0 ? ((__typeof(self))nil).key, (NSString *)nil : @#key) | |
#define ProtocolKey(protocol, key) (0 ? ((id <protocol>)nil).key, (NSString *)nil : @#key) |
NewerOlder