-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathUUObject.m
More file actions
49 lines (41 loc) · 1 KB
/
UUObject.m
File metadata and controls
49 lines (41 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// UUObject.m
// Useful Utilities - NSObject extensions
//
// Created by Jonathan on 3/4/13.
//
// License:
// You are free to use this code for whatever purposes you desire. The only requirement is that you smile everytime you use it.
//
// Contact: @cheesemaker or jon@threejacks.com
#import "UUObject.h"
#import <objc/runtime.h>
const unsigned long kUUDefaultUserKey = 0x04261978;
@implementation NSObject (UUFramework)
- (void) attachUserInfo:(id)userInfo
{
objc_setAssociatedObject(self, (const void*)kUUDefaultUserKey, userInfo, OBJC_ASSOCIATION_RETAIN);
}
- (id) userInfo
{
return objc_getAssociatedObject(self, (const void*)kUUDefaultUserKey);
}
- (void) attachUserInfo:(id)userInfo forKey:(const void*)key
{
if (key != nil)
{
objc_setAssociatedObject(self, key, userInfo, OBJC_ASSOCIATION_RETAIN);
}
}
- (id) userInfoForKey:(const void*)key
{
if (key != nil)
{
return objc_getAssociatedObject(self, key);
}
else
{
return nil;
}
}
@end