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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:55:44+00:00 2026-06-04T16:55:44+00:00

I have a core data in one of my application.All the data are populated

  • 0

I have a core data in one of my application.All the data are populated from server.At a point i have to check whether the data from the server is already existing in the core data or not.If it is already existing,just have to replace it.The checking can be done with a unique value that i have for each entry.How can i achieve this? This is what i have done:

` for(int i=0;i<[ar count];i++){
            NSFetchRequest * request = [[NSFetchRequest alloc] init];
         NSManagedObjectContext *context=[Server serverInfo].context;

            [request setEntity:[NSEntityDescription entityForName:@"Coupon" inManagedObjectContext:context]];
            [request setPredicate:[NSPredicate predicateWithFormat:@"upc_code = %@",[ [ar objectAtIndex:i]objectForKey:@"upc_code"]]];
            NSUInteger count = [context countForFetchRequest:request error:nil];
            [request release];
          //  [context ]

        if (count > 0){
            NSLog(@"found");}'

Here ar is the array fetching from the server.The context is the user can sometimes make edits in the entries from the server.I need all the data in the server synced with the device.

  • 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-04T16:55:45+00:00Added an answer on June 4, 2026 at 4:55 pm

    Don’t do a countForFetchRequest, in stead do executeFetchRequest:error: which will return an array with results. This array should have 0 or 1 results, more than 1 would be inconsistent since I assume that your upc_code is unique.

    If you have 0 results, create a new object in your context and set its properties

    If you have 1 result, just update your properties of that object that was returned by executeFetchRequest:error:

    And finally save your context and your done

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

Sidebar

Related Questions

In this test Core Data project, I have a one to many relationship from
I have a core data application that uses an NSPredicate in one of its
I have a Core Data based application which is built around one main entity.
I have an entity in core data that has 2 Attributes. One that is
I was learning Core Data and previously I have used SQLite in one of
I have several objects set up in Core Data, one of which is Deck
I am having a Core Data problem with NSFetchedResultsController . I have a one
I currently have the following in one solution: Core Project (data access, biz logic,
I have been building a core data application to administrate some data and I've
So I have 0.5MB XML file with data for my iPhone application. It's all

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.