Let's assume there is a UIView
that contains a UILabel
internally.
The UIView
's public interface is as follows in it's .h
:
@interface MyView : UIView
@property (nonatomic, copy) NSString *text;
@end
and privately within it's .m
:
@interface MyView ()
@property (nonatomic, strong) UILabel coolLabel;
@end
with the implementation in it's .m
:
@implementation
- (void)setText:(NSString *)text
{
self.coolLabel.text = text;
}
- (NSString *)text
{
return self.coolLabel.text;
}
@end
Looking at the public interface I declare @property (nonatomic, copy) NSString *text
with a copy
because the text is copied by the coolLabel
internally. However, I'm not sure if this is correct.
Should the declaration be @property (nonatomic, assign) NSString *text
with an assign
instead because my class isn't specifically performing the memory management? Or is my current interface declared correctly?
FYI, everything assumes ARC