XCode autocompletion of block type properties does not provide a block prototype
| Originator: | syncluz | ||
| Number: | rdar://12122594 | Date Originated: | 2012-08-17 |
| Status: | Duplicate/10193634 | Resolved: | |
| Product: | Developer Tools (XCode) | Product Version: | 4.4.1 (4F1003) |
| Classification: | Nice to have | Reproducible: | always |
17-Aug-2012 08:00 PM Lukas Zeller:
Summary:
When typing method calls with block parameters in XCode, autocompletion expands the block parameter into a skeleton implementation of the block, which is very handy.
However, when expanding a call to a setter method of a block type property, autocompletion does not realize that the value actually is a block, and does not expand it into the block implementation skeleton.
Workaround is to explicitly define the setter for the block type property.
Steps to Reproduce:
1) declare a property with a block type value:
// myObject.h
typedef void (^ZG2ButtonPressHandler)(BOOL aPressed);
@interface MyObject : NSView
@property(copy, nonatomic) ZG2ButtonPressHandler buttonPressHandler;
@end
2) in "myObject.m", within a method body, start typing
[self setButtonPress
3) autocompletion will suggest to expand setButtonPressHandler
Expected Results:
The expansion should be:
[self setButtonPressHandler:<#^(BOOL aPressed)buttonPressHandler#>]
Such that when the parameter is expanded, a method body skeleton would be generated like:
[self setButtonPressHandler:^(BOOL aPressed) {
<#code#>
}]
Actual Results:
The expansion that happens is just:
[self setButtonPressHandler:<#(ZG2ButtonPressHandler)buttonPressHandler#>
Which is not very useful
Notes:
My current workaround is to explicitly define the setter along with the property definition:
@property(copy, nonatomic) ZG2ButtonPressHandler buttonPressHandler;
- (void)setButtonPressHandler:(ZG2ButtonPressHandler)buttonPressHandler;
The explicit setter declaration makes autocompletion work as expected. However, this clutters interface declarations.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!