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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:36:51+00:00 2026-05-13T19:36:51+00:00

Example: I have a list of friends which I retrieve as XML from a

  • 0

Example: I have a list of friends which I retrieve as XML from a web server. On the device I want to store those friends with an update feature locally. But I only want to store NEW friends. To keep it simple I distinguish them by their first name only (yes thats bad!).

As the XML parser walks through the XML, it generates managed objects for all the friends and hangs them into the managed object context. But before I save the context, I want to get rid of all those “new” friends which are already in the database. Currently I have:

NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Friend" inManagedObjectContext:context]; 

NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; 

[request setEntity:entityDescription]; 

[request setPredicate:[NSPredicate predicateWithFormat:@"firstName == 'George'"]]; 
NSError *error = nil; 
NSArray *array = [context executeFetchRequest:request error:&error];

The problem is, probably: It will find the friends in the whole managed object context, so also those which are NOT in the database yet. How could I make sure that I only save those which are really new, and throw the duplicates away before saving?

  • 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-13T19:36:51+00:00Added an answer on May 13, 2026 at 7:36 pm

    Use a unique ID. Add an attribute to your Friend entity for it. For example, it could be the primary key from the web database.

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

Sidebar

Related Questions

I have two List's which I want to check for corresponding numbers. for example
I have an List<int> which contains 1,2,4,7,9 for example. I have a range from
I have a list of numbers, for example: list=[10,50,90,60] I want to sorte the
For example I have such query: Query q = sess.createQuery(from Cat cat); List cats
I have a question: I have a list (for example with Names from my
I have an app in android which retrieve a picture from http page.I'm asking
Case example: I have a long list of items, and when I put my
Possible Duplicate: Java - Regex problem I have list of URLs of types: http://www.example.com/pk/etc
I have a list of objects (for the sake of example, let's say 5).
I have a List that contains items, for example: 1) https:\\10.12.23\\ 2) https:\\12.23.12.25\\ 3)

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.