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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:41:34+00:00 2026-06-13T15:41:34+00:00

I am working with a core database to save my data that I get

  • 0

I am working with a core database to save my data that I get back from a webservice into my app. But this is very very slow. Any idea how this comes? What I do is the following. I have a class for getting the data from the webservice. like you can see over here.

     GenkData.h 

            + (NSArray *)getNews;
     GenkData.m
+ (NSDictionary *)executeGenkFetch:(NSString *)query
{
    query = [NSString stringWithFormat:@"%@", query];
    query = [query stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    // NSLog(@"[%@ %@] sent %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), query);
    NSData *jsonData = [[NSString stringWithContentsOfURL:[NSURL URLWithString:query] encoding:NSUTF8StringEncoding error:nil] dataUsingEncoding:NSUTF8StringEncoding];
    NSError *error = nil;
    NSDictionary *results = jsonData ? [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers|NSJSONReadingMutableLeaves error:&error] : nil;
    if (error) NSLog(@"[%@ %@] JSON error: %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), error.localizedDescription);
    // NSLog(@"[%@ %@] received %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), results);
    return results;
}

+ (NSArray *)getNews
{
    NSString *request = [NSString stringWithFormat:@"http://www.krcgenk.be/mobile/json/request/news/type/ipad"];
    return [[self executeGenkFetch:request] valueForKey:@"news"];
}

Then in my first view controller that shows up I have a method that for fetching my data in my core database.

- (void)fetchGenkDataIntoDocument:(UIManagedDocument *)document
{
    NSLog(@"Fetch data");
    dispatch_queue_t fetchQ = dispatch_queue_create("Genk fetcher", NULL);
    dispatch_async(fetchQ, ^{

        NSArray *news           = [GenkData getNews];

        [document.managedObjectContext performBlock:^{ // perform in the NSMOC's safe thread (main thread)

            int newsId          = 0;
            //int trainingIndex   = -1;
            for (NSDictionary *genkInfo in news) {
                NSLog(@"Begint met nieuwsitem");
                newsId++;
               [News newsWithGenkInfo:genkInfo inManagedObjectContext:document.managedObjectContext withNewsId:newsId];
                NSLog(@"Einde met nieuwsitem");
            }
 }];
    });
    NSLog(@"einde fethdata");
}

Next I have a category of the NSManagerd object subclass of news where I do the following.

+ (News *)newsWithGenkInfo:(NSDictionary *)genkInfo
    inManagedObjectContext:(NSManagedObjectContext *)context
                withNewsId:(int)newsId
{
    News *news = nil;

    news = [NSEntityDescription insertNewObjectForEntityForName:@"News"
                                                     inManagedObjectContext:context];

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"dd/MM/yyyy"];
    [dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT+0:00"]];
        NSDate *date = [dateFormatter dateFromString:[genkInfo objectForKey:NEWS_DATE]];
        news.title              = [genkInfo objectForKey:NEWS_TITLE];
        news.date               = date;
        news.genk_description   = [genkInfo objectForKey:NEWS_DESCRIPTION];
        news.imgurl             = [genkInfo objectForKey:NEWS_IMGURL];
        news.shortdescription   = [genkInfo objectForKey:NEWS_SHORTDESCRIPTION];
        news.url                = [genkInfo objectForKey:NEWS_URL];
        news.imagecopyright     = [genkInfo objectForKey:NEWS_IMAGECOPYRIGHT];
        news.news_id            = [NSNumber numberWithInt:newsId];

    return news;

}

I am doing the following proces like 10 times for 10 different entities. All of those attributes are mostly strings. Still this takes up to 10 minutes to load in all the data. Can somebody help me ?

Kind regards.

  • 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-13T15:41:35+00:00Added an answer on June 13, 2026 at 3:41 pm

    Dima’s answer of checking with the profiler helped me with this question and solved my problem

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

Sidebar

Related Questions

I am working on this core data app, and im not exactly shure how
I've been working on adding Core Data into my iPhone app, and I've been
I have been working on a Core Data iOS app that works perfectly through
I'm working on an iOS app. I have a Core Data database with a
I have a query here pulling data from MySQL database. It's working great.But what
I'm working on an iPhone app which graphs a large database, accessed through core-data,
im working with core-data for the first time, and my app is handling a
This is working fine in core php, but not in magento. $party_payment = new
I have a Core Data based mac application that is working perfectly well until
I am working with a core database, it is working in IOS 6 but

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.