Skip to content

Instantly share code, notes, and snippets.

@OneSadCookie
Created November 13, 2014 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OneSadCookie/c4a21911ccb5e3d7aa09 to your computer and use it in GitHub Desktop.
Save OneSadCookie/c4a21911ccb5e3d7aa09 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
@interface Foo : NSObject
@property (readwrite, copy) void (^array)();
@end
@implementation Foo
- (id)initWithError:(NSString **)errorHandle;
{
self = [super init];
if (self)
{
self.array = ^{
*errorHandle = @"Punk1";
};
}
return self;
}
- (void)test:(NSString **)errorHandle cb:(dispatch_block_t)cb;
{
self.array = ^{
*errorHandle = @"Punk2";
};
cb();
self.array = nil;
}
@end
int main(int argc, const char * argv[])
{
@autoreleasepool
{
{
NSString *e = nil;
Foo *foo = [[Foo alloc] initWithError:&e];
foo.array();
NSLog(@"Null: %@", e);
}
{
NSString *e = nil;
Foo *foo = [[Foo alloc] init];
[foo test:&e cb:^{
foo.array();
}];
NSLog(@"Not Null: %@", e);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment