CGRect type is a structure type. If I want to define a property as this type, should I use assign or retain attribute for this type?
@interface MyClass {
CGRect rect;
...
}
@property (nonatomic, assign) CGRect rect; // or retain?
or I have to write my own getter and setter?
Only
assignis possible for non-objects. (Before ARC, that includes CoreFoundation stuff, e.g. a CFArrayRef can only beassign.)You don’t need a custom getter and setter unless you don’t want to use
memcpyfor assignment.