This is an application that allows users to mark things. Tags are just strings.
The array of objects TagHoldercontains a list of all the tags used in the application, with a Boolean message, if a tag is selected, but this is an implementation detail.
The external interface calls two methods: selectedTagsand setSelectedTags:, which return and accept arrays of strings.
I would like these two methods to work as accessors for the declared property selectedTags.
Now, my question is:
What was the correct memory management semantics for the declaration for this property?
The sample code that I have in mind is this (the code is not tested, so please bear typos):
@interface TagInfo : NSObject
@property (strong, nonatomic) NSString *tag;
@property (nonatomic) BOOL selected;
@end
@interface SomeClass : NSObject
@property (memorytype, nonatomic) NSArray *selectedTags;
@end
@implementation TagHolder
- (NSArray *)selectedTags
{
NSPredicate *selPred = [NSPredicate predicateWithFormat: @"selected == YES"];
NSArray *selectedTagInfoObjects = [[self tagInfoArray] filteredArrayUsingPredicate: selPred];
NSArray *selectedTags = [selectedTagInfoObjects valueForKey: @"tag"];
return selectedTags;
}
- (void)setSelectedTags: (NSArray *)selectedTags
{
for (TagInfo *tagInfo in [self tagInfoArray]) {
tagInfo.selected = [selectedTags containsObject: tagInfo.tag];
}
}
@end
memorytype? , , , assign, copy unsafe_unretained, ?
ARC, , .