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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:58:34+00:00 2026-06-11T23:58:34+00:00

I’m doing a project using core data, and as far as I know anything

  • 0

I’m doing a project using core data, and as far as I know anything done in the core data thread has to remain in said thread.

I do a call to an API to download some news items and then load them into the database:

  [self.database.managedObjectContext performBlock:^{
    for (NSDictionary *itemInfo in result) {
      NSLog(@"%@", itemInfo);
      [Item createItemWithInfo:itemInfo inManagedObjectContext:self.database.managedObjectContext];
    }

    [self.database.managedObjectContext save:nil];
  }];

In my create method, besides setting up all the data in the objects I have an additional call to get an image related to the news item in question:

+ (Item *)createItemWithInfo:(NSDictionary *)info inManagedObjectContext:(NSManagedObjectContext *)context {
  Item *item;

  NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Item"];
  request.predicate = [NSPredicate predicateWithFormat:@"itemId = %@", [info valueForKeyPath:@"News.id_contennoticias"]];
  NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"itemId" ascending:YES];
  request.sortDescriptors = [NSArray arrayWithObject:sortDescriptor];

  NSError *error = nil;
  NSArray *matches = [context executeFetchRequest:request error:&error];

  if (!matches || ([matches count] > 1)) {
    // handle error
  } else if ([matches count] == 0) {
    item = [NSEntityDescription insertNewObjectForEntityForName:@"Item" inManagedObjectContext:context];
    item.itemId = [NSNumber numberWithInteger:[[info valueForKeyPath:@"News.id_contennoticias"] integerValue] ];
    item.title = [info valueForKeyPath:@"News.titulo_contennoticias"];
    item.summary = [info valueForKeyPath:@"News.sumario_contennoticias"];
    item.content = [info valueForKeyPath:@"News.texto_contennoticias"];

    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    dateFormat.dateFormat = @"yyyy-MM-dd hh:mm:ss";
    NSDate *creationDate = [dateFormat dateFromString:[info valueForKeyPath:@"News.fechacre_contennoticias"]];
    item.creationDate = creationDate;

    dispatch_queue_t imageDownloadQueue = dispatch_queue_create("image downloader", NULL);
    dispatch_async(imageDownloadQueue, ^{
      NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/files/imagenprincipal/%@", BASE_PATH, [info valueForKeyPath:@"News.imgprincipal"]]];
      NSData *imageData = [NSData dataWithContentsOfURL:url];
      dispatch_async(dispatch_get_current_queue(), ^{
        item.image = imageData;
      });
    });
  } else {
    item = [matches lastObject];
  }

  return item;  
}

On this part:

dispatch_async(dispatch_get_current_queue(), ^{
  item.image = imageData;
});

I’m getting the error, my app just dies there. Also it says that dispatch_get_current_queue() is deprecated in iOS 6.

  • 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-11T23:58:35+00:00Added an answer on June 11, 2026 at 11:58 pm

    Since dispatch_get_current_queue() is called from within a block on the imageDownloadQueue, why aren’t you using imageDownloadQueue directly? If you want to run it on the moc queue, then make sure not to use dispatch_get_current_queue().

    In general be careful with using dispatch_get_current_queue(). Quoting from the Dispatch Queues page in the Apple Concurrency Programming guide:

    Use the dispatch_get_current_queue function for debugging purposes or
    to test the identity of the current queue.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I am doing a simple coin flipping experiment for class that involves flipping a

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.