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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:29:04+00:00 2026-06-13T09:29:04+00:00

I’ve got an NSMutableArray that currently holds a bunch of Core Data entities like

  • 0

I’ve got an NSMutableArray that currently holds a bunch of Core Data entities like so:

NSFetchRequest *fetchReq = [[NSFetchRequest alloc]init];
[fetchReq setEntity:[NSEntityDescription entityForName:@"Subject"
                                inManagedObjectContext:self.managedObjectContext]];

subjectsArray = [self.managedObjectContext executeFetchRequest:fetchReq error:nil];

I then put this array in a dictionary:

_childrenDictionary = [NSMutableDictionary new];
[_childrenDictionary setObject:subjectsArray forKey:@"SUBJECTS"];

This dictionary is then used as the data for a Source List I have implemented. What I’m having issues with is deleting an object from the subjectsArray. I’ve tried this with the following code:

_selectedSubject = [subjectsArray objectAtIndex:0];
[subjectsArray removeObject:subjectToDelete];

Now this works fine, when I execute the following:

for (Subject *s in subjectsArray) {
        NSLog(@"Subjects: %@", [s title]);
    }

The Subject I selected to delete is no longer there and the Source List I have updates correctly after calling:

[_sidebarOutlineView reloadData];

The problem I am having though is that when I quit the application and open it up again, the Subject I previously deleted is still there.

The fetching of the core data entities into the array and dictionary is done inside applicationDidFinishLaunching. At the moment all this code is inside the AppDelegate file, which has a .h file that looks like this:

#import <Cocoa/Cocoa.h>
#import "Subject.h"

@interface LTAppDelegate : NSObject <NSApplicationDelegate, NSOutlineViewDelegate,     NSOutlineViewDataSource, NSMenuDelegate> {
    IBOutlet NSWindow *newSubjectSheet;
    IBOutlet NSWindow *newNoteSheet;
    IBOutlet NSWindow *newEditSheet;
    NSMutableArray *subjectsArray;
}

@property Subject *selectedSubject;
@property (assign)IBOutlet NSOutlineView *sidebarOutlineView;
@property NSArray *topLevelItems;
@property NSViewController *currentContentViewController;
@property NSMutableDictionary *childrenDictionary;
@property NSArray *allSubjects;

Any ideas as to what is causing to deleted Subject to reappear?

  • 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-13T09:29:05+00:00Added an answer on June 13, 2026 at 9:29 am

    You are removing the objects from the local array, but not the CoreData store itself.

    To remove an object from the Core Data store, you need to call managedObjectContext
    deleteObject:theObject
    on it, and then call managedObjectContent save:&error to persist it.

    If you are using table views, I would recommend checking out the NSFetchedResultsController as well.

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.