Skip to content

Instantly share code, notes, and snippets.

@swillits
Created November 13, 2014 06:24
Show Gist options
  • Save swillits/c15d6f0fb4c664c4318e to your computer and use it in GitHub Desktop.
Save swillits/c15d6f0fb4c664c4318e to your computer and use it in GitHub Desktop.
//
// main.m
// Blah
//
// Created by Seth Willits on 11/12/14.
// Copyright (c) 2014 Araelium Group. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface Foo : NSObject
@property (readwrite, copy) void (^array)();
@end
@implementation Foo
- (id)initWithError:(NSString **)errorHandle;
{
self = [super init];
self.array = ^(){
*errorHandle = @"Punk1";
};
return self;
}
- (void)test:(NSString **)errorHandle;
{
self.array = ^(){
*errorHandle = @"Punk2";
};
self.array();
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);
}
{
e = nil;
Foo * foo = [[Foo alloc] init];
[foo test:&e];
NSLog(@"Not Null: %@", e);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment