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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:30:57+00:00 2026-06-16T18:30:57+00:00

I’ve been working on an RSS Reader, using core data for caching. Like a

  • 0

I’ve been working on an RSS Reader, using core data for caching. Like a lot of people, I wanted to avoid duplicate entries, which led me to this question, and also this one.
But, there was another thing I wanted, I also wanted to give users the ability to delete articles, and avoid adding deleted articles again when refreshing a feed, that is if the deleted article still existed in the feed. So, my solution currently, is, to maintain another entity in my managed object context with unique identifiers (which how I identify each item in the feed) of deleted articles, I just add the identifier of the article that is being deleted to that entity, and check against it.

Now, here is a piece of code that I wrote to accomplish all of the above. This code is run every time a new item in the feed is parsed, during the parsing process.

    dispatch_queue_t checkQueue = dispatch_queue_create("com.feedreader.backgroundchecking", NULL);

    dispatch_async(checkQueue,^{
        NSMutableArray *mutablesortedArticles = [NSMutableArray arrayWithArray:self.feeds.sortedArticles];

        if (!mutablesortedArticles) {
            // Handle the error.
        }

        if ([[mutablesortedArticles valueForKey:@"identifier"]
             containsObject:article.identifier]) {
            NSLog(@"This article already exists");
            return;
        }else {
            NSMutableArray *mutabledeletedArticles = [NSArray arrayWithArray:self.alldeletedArticles];

            if (!mutabledeletedArticles) {
                // Handle the error.
            }

            if ([mutabledeletedArticles valueForKey:@"identifier"]
                 containsObject:article.identifier]) {
                NSLog(@"This article has been deleted");
                return;
            }else {
                Article *newArticle = [NSEntityDescription insertNewObjectForEntityForName:@"Article" inManagedObjectContext:self.managedObjectContext];

                newArticle.title = article.title;
                newArticle.date = article.date;
                newArticle.link = article.link;
                newArticle.summary = article.summary;
                newArticle.image = article.image;
                newArticle.identifier = article.identifier;
                newArticle.updated = article.updated;
                newArticle.content = article.content;
                newArticle.feed = self.feed;

                dispatch_async(dispatch_get_main_queue(),^{
                    NSError *error = nil;
                    [self.managedObjectContext save:&error];
                    if (error) {
                        NSLog(@"%@", error);
                    }
                });
            }
        }
    });

Both, self.feeds.sortedArticles and self.alldeletedArticles are fetched from managed object context before parsing starts.

My problem begins when this code is being run, the UI freezes, for 1-2 seconds (I tried it with a feed that had a little more than 500 articles in the managed object context). So, I guess my question is, is there a more efficient way to do what I’m trying to do here, one that hopefully doesn’t freeze the UI?
Perhaps a better way of dealing with deleted articles?

  • 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-16T18:30:58+00:00Added an answer on June 16, 2026 at 6:30 pm

    My first suggestion would be to handle deleted articles by added a “itemDeleted” property to the Article entity. Then you have only one list of objects to check when inserting new items.

    (Hint: Don’t call that attribute “deleted”. isDeleted is a built-in property of NSManagedObject, so that is likely to cause name collisions.)

    The next suggestion is to save the managed object context only after all items have been imported, and not after each each item (EDIT: See also Caffeine’s answer, which was posted while I was writing this.)

    Finally, searching each new item in the list of all articles separately is a pattern that does not scale well. Implementing Find-or-Create Efficiently in the “Core Data Programming Guide” describes a pattern that might be better:

    • for a list of to-be-inserted items, perform a fetch request that fetches all items of this list which are already present in the database,
    • traverse both the list of new items and the fetched list in parallel, to find out which items are really new and have to be inserted.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am using jsonparser to parse data and images obtained from json response. When
I have a jquery bug and I've been looking for hours now, I can't
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
I am using JSon response to parse title,date content and thumbnail images and place
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.