Deep copy of dictionaries gives Analyze error in Xcode 4.2

前端 未结 2 483
渐次进展
渐次进展 2020-11-27 22:25

I have the following method in a NSDictionary category, to do a deep copy, which works fine.

I just upgraded from Xcode 4.1 to 4.2, and the Analyze function gives tw

2条回答
  •  时光说笑
    2020-11-27 23:27

    Adding onto @Justin's answer, you can tell the compiler that -deepCopy returns a retained object by appending the NS_RETURNS_RETAINED attribute to the method's declaration like so:

    - (id) deepCopy NS_RETURNED_RETAINED;
    

    Alternatively, you can use explicitly control the method's "family" using the objc_method_family attribute like so:

    - (id) deepCopy __attribute__((objc_method_family(copy)));
    

    If you do this, the compiler will know that this method is in the copy family and returns a copied value.

提交回复
热议问题