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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:58:19+00:00 2026-06-10T23:58:19+00:00

I did some studies on this post . But none of its solution work

  • 0

I did some studies on this post. But none of its solution work for me. Let me explain what I did:

enter image description here

It’s actually very similar with the mentioned post.

Category.h

@class Category, Item;

@interface Category : NSManagedObject

@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSOrderedSet *items;
@property (nonatomic, retain) Category *parentcategory;
@property (nonatomic, retain) NSSet *subcategories;

@end

@interface Category (CoreDataGeneratedAccessors)

- (void)insertObject:(Item *)value inItemsAtIndex:(NSUInteger)idx;
- (void)removeObjectFromItemsAtIndex:(NSUInteger)idx;
- (void)insertItems:(NSArray *)value atIndexes:(NSIndexSet *)indexes;
- (void)removeItemsAtIndexes:(NSIndexSet *)indexes;
- (void)replaceObjectInItemsAtIndex:(NSUInteger)idx withObject:(Item *)value;
- (void)replaceItemsAtIndexes:(NSIndexSet *)indexes withItems:(NSArray *)values;
- (void)addItemsObject:(Item *)value;
- (void)removeItemsObject:(Item *)value;
- (void)addItems:(NSOrderedSet *)values;
- (void)removeItems:(NSOrderedSet *)values;
- (void)addSubcategoriesObject:(Category *)value;
- (void)removeSubcategoriesObject:(Category *)value;
- (void)addSubcategories:(NSSet *)values;
- (void)removeSubcategories:(NSSet *)values;

@end

In my view controller, I load one of the category:

NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:kEntityCategory];
request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor
                                                    sortDescriptorWithKey:kAttributeCategoryName ascending:YES
                                                    selector:@selector(localizedCaseInsensitiveCompare:)]];

NSError *error = nil;
AppDelegate* appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;

NSArray* data = [appDelegate.dataCenter.document.managedObjectContext executeFetchRequest:request error:&error];
if ( data.count > 0)
{
    self.category = [data objectAtIndex:0];
}

I have a button in navigation bar for testing purpose. When it’s clicked I’ll copy the first item and add to the end.

Item* item = [self.category.items objectAtIndex:0];

[self.category willChangeValueForKey:@"items"];
NSMutableOrderedSet *tempSet = [NSMutableOrderedSet orderedSetWithOrderedSet:self.category.items];
[tempSet addObject: item];
self.category.items = tempSet;
[self.category didChangeValueForKey:@"items"];

The problem is the item is not added to database at all. (I did some testing, for example, I modify the item content. It proves that the database has no problem at all.) But I don’t know the reason why the item is not to the database. Can anybody help? Thanks

  • 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-10T23:58:21+00:00Added an answer on June 10, 2026 at 11:58 pm

    The problem solved. There are two problems:

    1. Can’t insert/add an existing item
    2. I have a stupid name conflict. So the suggestion in this post is good.

    Thanks.

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

Sidebar

Related Questions

I did some updates to my application today but now admob dont work right
I did some searching for this, but it's a little too generic to pull
Did some investigating in this forum and others but I can't quite figure out
I did some googling to try to answer this question but even after that
I did some googling on the this found several references which did similar things
I did some reading on this, and from questions similar to mine, it looks
I did some experiments with MF_MENUBARBREAK , but with this I can only achieve
Did some googling and couldn't find a clear answer on this. My assumption is
I did some work on a project on one machine, then pushed to github
I did some research but all I could find was syncing data core with

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.