Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Won't Do
-
0.9.2
-
None
Description
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.