Created
September 2, 2016 14:56
-
-
Save SiarheiFedartsou/572a5b399eca1078380307b48fd50623 to your computer and use it in GitHub Desktop.
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
@class Foo; | |
@interface Foo2 : NSObject | |
- (void) boo:(Foo*)foo; | |
@property (nonatomic, strong) Foo* foo; | |
@end | |
@interface Foo : NSObject | |
@property (nonatomic, strong) Foo2* foo2; | |
- (instancetype) initWithFoo2:(Foo2*)foo2; | |
- (void) boo:(void(^)())block foo2:(Foo2*)foo2; | |
@end | |
@implementation Foo | |
- (instancetype) initWithFoo2:(Foo2*)foo2 | |
{ | |
if (self = [super init]) { | |
self.foo2 = foo2; | |
} | |
return self; | |
} | |
- (void) boo | |
{ | |
[self.foo2 boo:self]; | |
} | |
- (void) releaseFoo2 | |
{ | |
self.foo2 = nil; | |
} | |
@end | |
@implementation Foo2 | |
- (void) boo:(Foo*)foo | |
{ | |
self.foo = foo; | |
__weak Foo2* wself = self; | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ | |
// [wself boo]; | |
NSLog(@"%@", wself); | |
[wself.foo releaseFoo2]; | |
NSLog(@"%@", wself); | |
}); | |
} | |
- (void) boo | |
{ | |
NSLog(@"%@", self); | |
[self.foo releaseFoo2]; | |
NSLog(@"%@", self); | |
} | |
@end | |
@interface AppDelegate () | |
@end | |
@implementation AppDelegate | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
Foo2* foo2 = [[Foo2 alloc] init]; | |
Foo* foo = [[Foo alloc] initWithFoo2:foo2]; | |
[foo boo]; | |
// Override point for customization after application launch. | |
return YES; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment