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.m | |
// KVO | |
// | |
// Created by Damien DeVille on 10/22/13. | |
// Copyright (c) 2013 Damien DeVille. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
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
So: | |
id boxedValue = objc_msgSend(self, mappingSelector, instance, value, boxingParameters); | |
would become: | |
id boxedValue = ((id (*)(id, SEL, id, id, id))objc_msgSend)(self, mappingSelector, instance, value, boxingParameters); | |
The first `id` and `SEL` are basically `self` and `_cmd`, the first 2 arguments in any objc_msgSend. |
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
rax - accumulator | |
rbx - base | |
rcx - count | |
rdx - data | |
r8-15 | |
rsi - source index | |
rdi - destination index | |
rbp - base pointer |
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
// | |
// Created by Damien DeVille on 6/23/13. | |
// Copyright (c) 2013 Damien DeVille. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
#import <objc/runtime.h> | |
extern id _objc_setNilReceiver(id newNilReceiver); | |
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
@interface SomeViewController : UIViewController | |
@end | |
@implementation SomeViewController | |
- (IBAction)show:(id)sender | |
{ | |
UIImagePickerController *pickerController = [UIImagePickerController new]; | |
[pickerController setDelegate:(id)self]; |
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
@interface RetrievalOperation : NSOperation | |
+ (id)retrievalOperationWithBlock:(id (^)(void))block; | |
@property (readonly, strong, nonatomic) id result; | |
@end | |
@interface RetrievalOperation (/* Private */) | |
@property (readwrite, strong, nonatomic) id result; | |
@property (copy, nonatomic) id (^block)(void); | |
@end |
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
#if TARGET_OS_IPHONE | |
#import <MobileCoreServices/MobileCoreServices.h> | |
#else | |
#import <CoreServices/CoreServices.h> | |
#endif | |
/* | |
MIME type to UTI | |
*/ | |
NSURLResponse *response = ... // assume a URL response from somewhere else. |
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)printViewHierarchy:(UIView *)view | |
{ | |
if (view == nil) | |
return; | |
NSLog(@"%@", view); | |
for (UIView *subview in [view subviews]) | |
{ | |
[self printViewHierarchy: subview]; |
NewerOlder