You need to provide a type when defining a variable outside of a function. You can achieve that by first defining a type for your block, or declaring and defining the block in one line.
This works for me:
MyClass.h:
#import <Foundation/Foundation.h>
@interface MyClass : NSObject
- (void)myMethod;
@end
MyClass.m
#import "MyClass.h"
typedef void (^MyBlockType) (id sender);
MyBlockType myBlock = ^(id sender) {
NSLog(@"It works!");
};
@implementation MyClass
- (void)myMethod {
myBlock(nil);
}
@end
Then, elsewhere...
MyClass *myClass = [MyClass new];
[myClass myMethod]; // Prints "It works!"
I recommend you read Declaring and Creating Blocks in the Blocks Programming Topics.