This template let's you easily implement a property getter like this:
- (UIView *)myView {
if (!_myView) {
_myView = [UIView new];
}
return _myView;
}
This template let's you easily implement a property getter like this:
- (UIView *)myView {
if (!_myView) {
_myView = [UIView new];
}
return _myView;
}
# .gitignore in use by Joris Kluivers | |
# | |
# Latest version: | |
# https://gist.github.com/gists/1923197 | |
*.DS_Store | |
# Xcode | |
*.pbxuser | |
*.mode1v3 |
It's 8:00 o'clock on a Friday | |
The regular crowd shuffles in | |
there's an old man sitting next to me | |
making love to his beer | |
la la di di da | |
la la di di da | |
Sing us a song, you're the piano man! | |
sing us a song tonight |
// clang -framework Foundation -fobjc-arc -O3 test.m | |
#import <Foundation/Foundation.h> | |
@interface Slice : NSObject | |
@property NSInteger start; | |
@property NSInteger length; | |
@end | |
@implementation Slice |
# Using https://github.com/Anviking/Decodable as example: | |
xcodebuild -sdk appletvsimulator -project Decodable.xcodeproj -configuration Release -scheme Decodable-tvOS ONLY_ACTIVE_ARCH=NO clean build | |
# This fails with http://www.openradar.me/22993940 |
static NSData *PSPDFCalculateSHA256FromFileURL(NSURL *fileURL, CC_LONG dataLength, NSError **error) { | |
NSCParameterAssert(fileURL); | |
NSData *shaData; | |
int fd = open(fileURL.path.UTF8String, O_RDONLY); | |
if (fd < 0) { | |
if (error) *error = [NSError pspdf_errorWithCode:PSPDFErrorCodeUnableToOpenPDF description:@"Failed to open file for calculating SHA256."]; | |
return nil; | |
} |
@implementation UIPopoverPresentationController (PSPDFAdditions) | |
+ (void)load { | |
PSPDFSwizzleMethodImplementation(self, @selector(containerViewWillLayoutSubviews), ^(UIPopoverPresentationController *_self) { | |
// Refresh bar button view internals | |
[_self pspdf_updateBarButtonView]; | |
((void( *)(id, SEL))objc_msgSend)(_self, PSPDFPrefixedSelector(containerViewWillLayoutSubviews)); | |
}); | |
} |
- (IBAction)handleTap:(id)sender | |
{ | |
BOOL isHiding = !_statusBarHidden; | |
_statusBarHidden = isHiding; | |
[UIView animateWithDuration:UINavigationControllerHideShowBarDuration delay:0 options:0 | |
animations:^{ | |
[self setNeedsStatusBarAppearanceUpdate]; | |
} | |
completion:NULL]; |
static NSInteger NSJSONReadingFuckNSNulls = (1UL << 3); | |
@implementation NSJSONSerialization (FuckNulls) | |
+ (void)load { | |
Method originalMethod = class_getClassMethod(self, @selector(JSONObjectWithData:options:error:)); | |
IMP swizzledImplementation = imp_implementationWithBlock([^id (id _self, NSData *_data, NSJSONReadingOptions _opt, NSError **_error){ | |
NSInputStream *stream = [NSInputStream inputStreamWithData:_data]; | |
[stream open]; | |
- (NSString *)tableView:(UITableView *)tableView titleForSwipeAccessoryButtonForRowAtIndexPath:(NSIndexPath *)indexPath { | |
return @"More"; | |
} | |
- (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath { | |
NSLog(@"I wanted to be a pretty public API, but then time ran out and they forgot me..."); | |
// Hide the More/Delete menu. | |
[self setEditing:NO animated:YES]; | |
} |