Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
static char fooKey;
|
||||
static void *fooKey = &fooKey; // one way to define a unique key is a pointer variable that points to itself
|
||||
|
||||
int main (int argc, const char *argv[]) {
|
||||
@autoreleasepool {
|
||||
|
|
@ -9,10 +9,10 @@ int main (int argc, const char *argv[]) {
|
|||
id e = [[NSObject alloc] init];
|
||||
|
||||
// set
|
||||
objc_setAssociatedObject(e, &fooKey, @1, OBJC_ASSOCIATION_RETAIN);
|
||||
objc_setAssociatedObject(e, fooKey, @1, OBJC_ASSOCIATION_RETAIN);
|
||||
|
||||
// get
|
||||
NSNumber *associatedObject = objc_getAssociatedObject(e, &fooKey);
|
||||
NSNumber *associatedObject = objc_getAssociatedObject(e, fooKey);
|
||||
NSLog(@"associatedObject: %@", associatedObject);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue