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 7659753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:22:28+00:00 2026-05-31T13:22:28+00:00

I want to store NoteObjects in Core Data. Normally, a NoteObject has a NSString

  • 0

I want to store NoteObjects in Core Data. Normally, a NoteObject has a NSString *mainText and an NSMutableArray *arrayOfTags (an array of NSStrings). I want to now use Core Data, but arrays are a tricky matter with core data. Typically a NoteObject won’t have more than 50 tags in its array. So how should I model this? I have two options:

  1. Use a transformable property to store the array
  2. Use a to-many relationship, which I’ve read is the more “legit” way to do it.

Which one should I use and why? And how would I implement a to-many relationship with my simple structure? I can’t seem to wrap my fingers around that concept.

  • 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-05-31T13:22:29+00:00Added an answer on May 31, 2026 at 1:22 pm

    Use to-many relationship. Because it’s way better and easier during fetch requests. See the screenshots below. Pay attention to the Relationship manager on the right side, set “To-Many Relationship” from your NoteObject to Tags. Ignore the Player entity.

    Oh and pay attention to the “Delete Rule”. You might want to delete all the tags associated with a given NoteObject. So set it to Cascade in that case.

    NoteObject entityenter image description here

    Tag entityenter image description here

    –Edit:

    To add multiple tags you need to first fetch your NoteObject – I assume there will be some sort of ID parameter which you’ll use to distinguish NoteObjects. CoreData will automatically generate the add/remove methods for Tags. You’ll need to use code similar to the one below:

    - (void)addTags:(NSArray *)tags toNoteObjectWithID:(NSString *)noteID {
      NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"NoteObject"];
      NSPredicate *pred = [NSPredicate predicateWithFormat:@"noteID == %@", noteID];
      [fetchRequest setPredicate:pred];
      NoteObject *noteObject = [[[self managedObjectContext] executeFetchRequest:fetchRequest error:nil] lastObject];
    
      for (NSString *tag in tags) {
        Tag *t = [NSEntityDescription insertNewObjectForEntityForName:@"Tag"
                                               inManagedObjectContext:[self managedObjectContext]];
        t.body = tag;
        t.noteObject = noteObject;
        [noteObject addTagsObject:t];
      }
      [self saveContext];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to store two NSMutableArray that I use as global array in AppDelegate.
I am a new developer on Android and I want store user data in
I want to store the data returned by $_SERVER[REMOTE_ADDR] in PHP into a DB
I want to store a very large amount of vector data on a server
Some code here, I want store mysql query result into an array with php,
i Just in windowsphone . i want store data as record in WP .
I want to store history data in a sqlite db. a max of 20
I want to store some data in the content provider, so some of my
I want store data from an html page to a text file using javascript
I want to store an array of information, with a subset of information for

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.