Created
February 24, 2016 03:29
-
-
Save fjolnir/353de6b5f451686580d8 to your computer and use it in GitHub Desktop.
KVC does not work with typedefs
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 <Foundation/Foundation.h> | |
typedef NSObject Foobar; | |
@interface Klass : Foobar | |
@property Foobar *baz; | |
@end | |
@implementation Klass | |
@end | |
int main(int argc, char *argv[]) { | |
@autoreleasepool { | |
Klass *obj = [Klass new]; | |
NSLog(@"%s", @encode(typeof(obj.baz))); // Gets @encoded like `struct { NSObject } *` | |
obj.baz = @123; | |
NSLog(@"%@", obj.baz); | |
[obj setValue:@321 forKey:@"baz"]; // Crash | |
NSLog(@"%@", [obj valueForKey:@"baz"]); // Crash | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use @compatibility_alias;
e.g. @compatibility_alias Foobar NSObject