Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7998393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:12:17+00:00 2026-06-04T15:12:17+00:00

This is for an app that allows users to tag things. Tags are just

  • 0

This is for an app that allows users to tag things. Tags are just strings.

An array of TagHolder objects holds a list of all tags in use in the app, with a boolean telling if the tag is selected, but this is an implementation detail.

The external interface calls for two methods, selectedTags, and setSelectedTags: which return and accept an arrays of strings.

I would like these two methods to work as accessors for a declared property selectedTags.

Now, my question is:

What would be the correct memory management semantics to declare for that property?

The code pattern that I have in mind is this (code not tested, so please bear with 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
{
    // tagInfoArray is an array of all TagInfo objects
    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

What should memorytype be? Obviously not strong or weak, but I think it could be any one of assign, copy or even unsafe_unretained, but which one is the most correct for a computed property with an object value?

I normally use ARC, but I guess the question is the same in an environment with manual retain count.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:12:17+00:00Added an answer on June 4, 2026 at 3:12 pm

    memorytype is significant only when you @synthesize your property accessors. Since you are providing your own implementation for both the getter and the setter, the things you put in parentheses after @property are ignored; I usually put readonly or readwrite there, just to remind myself of what kind of access is available on these properties.

    Your code is correct, it will work without creating memory issues with or without ARC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that allows users to generate objects, and store them (in
I have a blog-style app that allows users to tag each post with topics.
My app allows users to attach tags to certain model objects (subclasses of NSManagedObject).
So I'm working on this site web app that should let users easily chat
I wrote an app that allows users to store text articles in Core Data.
I'm creating a web app that allows users to enter a number of colors,
We have an app that allows users to send e-mails from our system. It
I have a Rails app that allows users to build up a network structure
I'm building an iPhone app that, among other things, allows the user to take
This is a weird one. I'm working on an app that allows for offline

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.