Is it possible to define an Objective-C block property but still have full-code completion in Xcode 4?
If I use a typedef to define the block:
typedef void (^CompletionBlock)(MyObject *myObj);
and then define the property:
@property (nonatomic, copy) CompletionBlock completionBlock;
and then @synthesize
the property I don't get full code completion when calling the setter. Xcode will use the typedef and because of this, the code completion doesn't use the full block syntax complete with block parameters, it uses the typedef.
If I define a method prototype in the header that uses the full block syntax instead of the typedef:
@property (nonatomic, copy) void (^completionBlock)(MyObject *myObj);
and then I use @synthesize
, the provided setter comes close to using the full code completion syntax but crucially it leaves out the parameter names:
[self setCompletionBlock:(void (^)(MyObject *)) { ... }
Finally, if I try to @synthesize
and then override the setter implementation or put the prototype in the header:
- (void)setCompletionBlock:(void (^)(MyObject *myObj))completionBlock {...}
A warning is raised stating that the property type does not match the accessor type. No matter how I try to finagle the syntax, I'm not able to both define a block property and a setter that has the full syntax for code completion. Can I have my cake and eat it too?
Thanks!
typedef
at all? For reduced functionality and a semi-redundant line of code? Maybe this is Apple's way of saying... "don't do that!"??