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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:29:01+00:00 2026-05-12T20:29:01+00:00

I have a situation where I’m lazy loading images from the www. It’s a

  • 0

I have a situation where I’m lazy loading images from the www.
It’s a list of items, when one item is tapped, a detail view is pushed to a nav controller.

In that detail view the item has an image, which first is a default image, and I want to start loading it’s image from a URL.

So what I do is create an object which once initialized detaches a new thread which in turn loads the content and afterwards notifies my view that the data is loaded:

// in MyLoader:
- (MyLoader *)initWithUrl:(NSURL *)url requester:(id)requester {
    self.url = url;
    self.requester = requester; // both are nonatomic, retain properties
    [self performSelectorInBackground:@selector(loadIt) withObject:nil];
}

- (void)loadIt {
    NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init];
    NSData *data = [NSData dataWithContentsOfURL:url];
    [requester performSelectorOnMainThread:@selector(dataReady) withObject:data waitUntilDone:YES;
    [arp release];
}

// in MyRequester:
- (void)somewhere {
    MyLoader *loader = [[[MyLoader] alloc] initWithUrl:someUrl requester:self] autorelease];
    // then I retain loader somewhere, it's more complicated but I have verified that it's properly retained.
}

A few notes:

  1. First I thought there might be a problem with some of the variables. I put a breakpoint right before performSelectorOnMainThread and confirmed that data and requester were both OK.

  2. Then I thought it was caused by passing the NSData across the threads, so I changed withObject:nil. It still crashes.

  3. When I further investigated, the crash was very strange. I specified waitUntilDone:YES, I’ve placed a breakpoint in the requester‘s dataReady. But the performSelectorOnMainThread call returns (it reaches the breakpoint after it) while not reaching the breakpoint inside dataReady. BTW, - (void)dataReady:(NSData*)‘s body for now only contains int x = 1; (to place a breakpoint on). Also, I’ve tried setting waitUntilDone:NO, it still crashes.

  4. The selector isn’t performed (the breakpoint is not reached), but the crash happens a short while after the call.

Does anyone have any idea what’s wrong?

This is obvious, but just to be clear, if I just comment out the [requester performSelectorOnMainThread... part, it doesn’t crash.

Also, here’s a stack trace, but it’s not helpful at all.

#0  0x00a71004 in ___TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION___ ()
#1  0x93436e3b in objc_exception_throw ()
#2  0x0028aca6 in __NSThreadPerformPerform ()
#3  0x00a098e1 in CFRunLoopRunSpecific ()
#4  0x00a08c48 in CFRunLoopRunInMode ()
#5  0x0005a78d in GSEventRunModal ()
#6  0x0005a852 in GSEventRun ()
#7  0x0168a003 in UIApplicationMain ()
#8  0x000028d4 in main (argc=1, argv=0xbffff100) at /Users/myName/Document/appName/main.m:14
  • 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-12T20:29:01+00:00Added an answer on May 12, 2026 at 8:29 pm

    You have:

    [requester performSelectorOnMainThread:@selector(dataReady) withObject:data waitUntilDone:YES;
    

    should be:

    [requester performSelectorOnMainThread:@selector(dataReady:) withObject:data waitUntilDone:YES;
    

    notice: @selector(dataReady:) (with colon)
    Since you’re passing an argument to the method, it’s presumed data ready is defined something like:

    - (void) dataReady:(NSData *)theData ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have situation in which I read a record from a database. And if
I have situation where i have column in mysql table from which i populate
I have situation when one of tables rich size 2G and after it I
I have a situation where I intended to step away from the object oriented
I have a situation where I need to ensure that there is only one
I have one situation I don't know how to solve... I have a rails
I have situation where I want to extract multiple values from multiple source objects
I have this situation: I have a page where I have a list of
I have situation when i want to add data from column formCompany, formPlace in
I have situation where a publisher application essentially keeps a view model up to

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.