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

  • Home
  • SEARCH
  • 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 685841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:57:48+00:00 2026-05-14T01:57:48+00:00

My objective is to abort the NSXMLParser when I parse an item that already

  • 0

My objective is to abort the NSXMLParser when I parse an item that already exists in cache. The basic flow of the program works like this:

1) Program starts and downloads an XML feed. Each item in the feed is represented by a custom object (FeedItem). Each FeedItem gets added to an array.

2) When the parsing is complete the contents of the array (all FeedItem objects) are archived to the disk.

The next time the program is executed or the feed is refreshed by the user I begin parsing again; however, since a cache (array) now exists as each item is parsed I want to see if the object exists in the cache. If it does then I know I have downloaded all the new items and no longer need to continue parsing.

What I am learning, I think, is that I can’t use indexOfObject or indexOfObjectIDenticalTo: because these really seem to be checking to see that the objects are using the same memory address (thus identical).

What I want to do is see if the contents of the object are equal (or at least some of the contents). I’ve done some research and found that I can override the IsEqual method; however, I really don’t want to iterate/enumerate through the entire cache contents table for every newly parsed XML FeedItem. Is iterating through the collection and testing each one for equality the only way to do this or is there a better technique I am not aware of?

Currently I am using the following code though I know it needs to change:
NSUInteger index = [self.feedListCache.feedList indexOfObject:self.currentFeedItem];
if (index == NSNotFound) {
}

  • 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-14T01:57:49+00:00Added an answer on May 14, 2026 at 1:57 am

    As an alternative, perhaps you could also maintain a dictionary of items. IIRC, RSS and Atom both specify that each item has a unique key (or maybe just a link, in the case of RSS?). If you use those unique identifiers as the dictionary keys, that would give you a quick way to determine whether you’ve already seen an item that matches the one you just parsed.

    So, in psuedocode, it might work something like this:

    FeedItem* item;
    NSMutableArray* allItems;
    NSMutableDictionary* itemIndex;
    
    // if this is not the first run, load existing stuff into allItems and itemIndex
    // set up the parser
    
    while( item = [parser nextItem] ) {
      FeedItem* existingItem = [itemIndex objectForKey:[item uniqueKey]];
      if( existingItem == nil ) {
        // haven't seen this item before
        [allItems addObject:item];
        [itemIndex setObject:item forKey:[item uniqueKey]];
      }
      else {
        // done parsing
        break;
      }
    }
    
    // clean up parser, save items to disk, etc.
    

    A warning, though: it is possible for someone to update an item in a feed (say, change the title after it’s been published). So you might not necessarily want to stop parsing as soon as you see an item that you’ve seen before. One refinement to my suggestion above might be to compare the publication dates of the cached item and the newly-parsed item. (But even that isn’t foolproof.)

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

Sidebar

Related Questions

This is question about Objective-C. I wrote the program that uses regular expression with
Coming from a C++ background, one thing that confuses me about Objective C is
I wonder about Objective-C style. I have FooClass.[hm] that depends on BarClass.[hm] for its
One book for about iPhone programming instantiates classes like this: [[Class alloc] init] Another
Possible Duplicate: What are best practices that you use when writing Objective-C and Cocoa?
I am getting an error in Xcode that says whatEverVariable is undeclared This is
There are a couple of things about Objective-C that are confusing to me: Firstly,
Until five minutes I was sure that my understanding about Objective c reference counting
This is my first time using Protocols in Objective-C, and I'm running into a
I've a simple question about objective-c / objective-j syntax. This is a method dataForItemsAtIndexes

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.