Skip to content

Commit

Permalink
修改说明
Browse files Browse the repository at this point in the history
  • Loading branch information
leichunfeng committed Jun 28, 2015
1 parent 2ce9785 commit fd09ac8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
# AssociatedObjects

我的博文[《Objective-C Associated Objects 的实现原理》](http://blog.leichunfeng.com/blog/2015/06/26/objective-c-associated-objects-implementation-principle/)的完整配套代码。

``` objc
__weak NSString *string_weak_assign = nil;
__weak NSString *string_weak_retain = nil;
__weak NSString *string_weak_copy = nil;

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];

self.associatedObject_assign = [NSString stringWithFormat:@"leichunfeng1"];
self.associatedObject_retain = [NSString stringWithFormat:@"leichunfeng2"];
self.associatedObject_copy = [NSString stringWithFormat:@"leichunfeng3"];

string_weak_assign = self.associatedObject_assign;
string_weak_retain = self.associatedObject_retain;
string_weak_copy = self.associatedObject_copy;
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
// NSLog(@"self.associatedObject_assign: %@", self.associatedObject_assign); // Will Crash
NSLog(@"self.associatedObject_retain: %@", self.associatedObject_retain);
NSLog(@"self.associatedObject_copy: %@", self.associatedObject_copy);
}
```

0 comments on commit fd09ac8

Please sign in to comment.