THRIFT-4586: Cocoa generator generates NSString with copy instead of strong.
Client: [cocoa]
diff --git a/compiler/cpp/src/thrift/generate/t_cocoa_generator.cc b/compiler/cpp/src/thrift/generate/t_cocoa_generator.cc
index 5bed2d7..ac644f5 100644
--- a/compiler/cpp/src/thrift/generate/t_cocoa_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_cocoa_generator.cc
@@ -238,6 +238,12 @@
std::string getter_name(string field_name);
std::string setter_name(string field_name);
+ bool type_can_be_copy(t_type* ttype) {
+ ttype = get_true_type(ttype);
+
+ return ttype->is_string();
+ }
+
bool type_can_be_null(t_type* ttype) {
ttype = get_true_type(ttype);
@@ -3011,7 +3017,9 @@
std::ostringstream render;
render << "@property (";
- if (type_can_be_null(tfield->get_type())) {
+ if (type_can_be_copy(tfield->get_type())) {
+ render << "copy, ";
+ } else if (type_can_be_null(tfield->get_type())) {
render << "strong, ";
} else {
render << "assign, ";