Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // NSObject+arcAgnostics.m
- //
- // Created by Jonathan Annett on 1/11/13.
- // Copyright (c) 2013 Sophtwhere. All rights reserved.
- //
- #import "NSObject+arcAgnostics.h"
- typedef void(^MyCustomBlock)(NSObject*thing);
- typedef BOOL(^MyCustomBlock2)(NSObject*thing);
- @implementation NSObject (arcAgnostics)
- -(id) __SELF__{
- return self;
- }
- -(void) __NOP__ {
- // literally do nothing. (NOP = NO OPERATION)
- }
- +(void) test {
- static NSDictionary *mydict;
- @autoreleasepool {
- mydict = @{ @"key" : @"user"};
- }
- NSLog(@"hello %@",mydict[@"key"]);
- dispatch_block_t greeting = ^{
- NSLog(@"hello");
- };
- MyCustomBlock greeting2 = ^(NSObject *thing){
- NSLog(@"hello %@",thing);
- };
- MyCustomBlock2 greeting3 = ^BOOL(NSObject *salutation){
- NSLog(@"%@ multiverse(s)",salutation);
- return YES;
- };
- greeting();
- dispatch_block_t deferred_greeting = Block_copy(greeting);
- MyCustomBlock deferred_greeting2 = Block_copy(greeting2);
- MyCustomBlock2 deferred_greeting3 = Block_copy(greeting3);
- double delayInSeconds = 2.0;
- dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
- dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
- deferred_greeting();
- deferred_greeting2(@"universe");
- if(deferred_greeting3(@"howdie")) {
- NSLog(@"so long and thanks for all the fish");
- };
- Block_release(deferred_greeting);
- Block_release(deferred_greeting2);
- Block_release(deferred_greeting3);
- });
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement