Created
November 8, 2010 17:26
-
-
Save kylesluder/667967 to your computer and use it in GitHub Desktop.
This file contains 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
#import <Foundation/Foundation.h> | |
@protocol Foo | |
@property (readonly, nonatomic) int blah; | |
@end | |
typedef void (^bk)(void); | |
@interface Foo : NSObject<Foo> | |
{ int v; } | |
- (bk)makeBlock:(id<Foo>)otherFoo; | |
@end | |
@implementation Foo | |
- (int)blah { | |
NSLog(@"Blah"); | |
return 1; | |
} | |
- (bk)makeBlock:(id<Foo>)otherFoo { | |
return [^{ self->v = otherFoo.blah; } copy]; | |
} | |
@end | |
bk mkBlock(Foo* f) { | |
return [^{ [f blah]; } copy]; | |
} | |
int main(int argc, char **argv) { | |
NSAutoreleasePool *pool __attribute__((unused)) = [NSAutoreleasePool new]; | |
Foo *f = [Foo new], *g = [Foo new]; | |
bk b = [f makeBlock:g]; | |
b(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment