Wes Henderson created THRIFT-3029:
-------------------------------------
Summary: Getters for fields defined with uppercase names do not
work
Key: THRIFT-3029
URL: https://issues.apache.org/jira/browse/THRIFT-3029
Project: Thrift
Issue Type: Bug
Components: Cocoa - Compiler
Affects Versions: 0.9.2
Reporter: Wes Henderson
Priority: Critical
Using a thrift file such as:
struct Foo {
1: required i32 Bar;
2: required i32 baz;
}
The generated Objective-C object, "baz" will have working getters but "Bar"
will not. For example, after setting bar to 5 and baz to 9, I get the following
output depending on the syntax:
[foo bar] => 0
[foo Bar] (private method invoked by performSelector) => 5
foo.bar => 0
foo.Bar => 0
foo.baz => 9
The problem is that the generated header specifies a lowercase getter:
@property (nonatomic, getter=bar, setter=setBar:) int32_t Bar;
Whereas the .m file uses uppercase:
- (int32_t) Bar {
return __Bar;
}
When the Objective-C compiler sees that there is no lowercase getter
implementation provided, it automatically generates one (this is supposed to be
a convenience of the @property syntax). So effectively, two getters are
defined: a lowercase one that does not work, and an uppercase one that does
work but is private.
As a workaround one can define all their fields beginning with a lowercase
letter, if possible.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)