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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:40:55+00:00 2026-06-12T03:40:55+00:00

My app requires to get data from a .Net WCF service when the device

  • 0

My app requires to get data from a .Net WCF service when the device is connected to WiFi.If there’s a new row added on the server,it should add it to its CoreData database. I am using a NSDictionary for comparing the local objects with the remote objects. The code is:

-(void)handleGetAllCategories:(id)value
{
    if([value isKindOfClass:[NSError class]])
    {
        NSLog(@"This is an error %@",value);
        return;
    }

    if([value isKindOfClass:[SoapFault class]])
    {
        NSLog(@"this is a soap fault %@",value);
        return;
    }

    NSMutableArray *result = (NSMutableArray*)value;
    NSMutableArray *remoteObj = [[NSMutableArray alloc]init];

    for (int i = 0; i < [result count]; i++)
    {
        EDVCategory *catObj = [[EDVCategory alloc]init];
        catObj = [result objectAtIndex:i];
        [remoteObj addObject:catObj];
    }

    NSArray *remoteIDs = [remoteObj valueForKey:@"categoryId"];

    NSFetchRequest  *request = [[[NSFetchRequest alloc] init]autorelease];
    request.predicate = [NSPredicate predicateWithFormat:@"categoryId IN %@", remoteIDs];

    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Categories" inManagedObjectContext:__managedObjectContext];
    [request setEntity:entity];
    NSMutableArray *results = [[NSMutableArray alloc]initWithArray:[__managedObjectContext executeFetchRequest:request error:nil]];

    NSArray *existingIDs = [results valueForKey:@"categoryId"];
    NSDictionary *existingObjects = [NSDictionary dictionaryWithObjects:results forKeys:existingIDs];

    for (NSDictionary *remoteObjectDic in remoteObj) 
    {
        Categories *existingObject = [existingObjects objectForKey:[remoteObjectDic valueForKey:@"categoryId"]];

        if (existingObject) 
        {
            NSLog(@"object exists");
        } 
        else 
        {
            NSLog(@"create new local object");
//            Categories *newCategory;
//            newCategory = [NSEntityDescription insertNewObjectForEntityForName:@"Categories" inManagedObjectContext:__managedObjectContext];           
//            [newCategory setCategoryId:[NSNumber numberWithInt:[[remoteObjectDic objectForKey:@"categoryId"]intValue]]];
//            [newCategory setCategoryName:[remoteObjectDic objectForKey:@"categoryName"]];  
//            [newCategory setDocCount:[NSNumber numberWithInt:[[remoteObjectDic objectForKey:@"docCount"]intValue]]];
//            [newCategory setCategoryType:[NSNumber numberWithInt:[[remoteObjectDic objectForKey:@"categoryType"]intValue]]];
//            [newCategory setSubCategoryId:[NSNumber numberWithInt:[[remoteObjectDic objectForKey:@"subCategoryId"]intValue]]];
//            [__managedObjectContext insertObject:newCategory];
        }
    }
[my_table reloadData];
}

The problem is,I am not able to extract values from the remote object and assign it to the NSManagedObject.I have commented the code which (according to me) should save the values in new object to the managed object. Can someone please help me achieve this?

Thanks

  • 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-12T03:40:56+00:00Added an answer on June 12, 2026 at 3:40 am

    Here is an example of a save I did in a recent project. I have somethings in wrappers so fetching a managed object and saving look a little weird on my end. Really the only major difference I see is the act of saving. Are you saving the new NSManagedObject elsewhere in the code?

    dict = (NSDictionary*)data;
            @try {
                if (dict) {
                    CaretakerInfo* info = [GenericDataService makeObjectWithEntityName:NSStringFromClass([CaretakerInfo class])];
                    [info setName:[dict valueForKey:@"name"]];
                    [info setImageURL:[dict valueForKey:@"photo"]];
                    [info setCaretakerID:[dict valueForKey:@"id"]];
                    [GenericDataService save];
                }
                else {
                    theError = [Error createErrorMessage:@"No Data" Code:-42];
                }
            }
            @catch (NSException *exception) {
                //return an error if an exception
                theError = [Error createErrorMessage:@"Exception Thrown While Parsing" Code:-42];
            }
    

    If not it should looks something like this…

         NSError *error = nil;
         [context save:&error];
    

    If you have anymore information about what’s happening when you extract or assigning data that would be helpful (error/warning/log messages).

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

Sidebar

Related Questions

I am new with Silverlight and I can get the data from my database
I want my android app to get data from an online database. Here are
The iPhone app that I am working on requires GET calls to a 3rd
I'm developing an app which requires the system to get the touch events even
My android app requires that the device has an SDcard and that SDcard is
i want to populate this json http://www.godsgypsychristianchurch.net/music.json using a get request, there are multiple
I built app for device with Microsoft.Synchronization services for Ado.net. I picked three assemblies:
I am developing an Android App that gets some data from a web server,
I'm using Razor and Data Annotations in a .NET 4.5 MVC app. This is
I have simple Sinatra app. web.rb: require 'sinatra' get '/' do Hello end Gemfile:*

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.