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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:11:18+00:00 2026-05-23T12:11:18+00:00

I can successfully retrieve data asynchronously through NSURLConnection from any other part in the

  • 0

I can successfully retrieve data asynchronously through NSURLConnection from any other part in the code base except in the canDrawMapRect function in my subclassed TileOverlayView class.

I’m modifying the MapKit sample called tileMap to download tiles from a server and overlay that information on the map. In the canDrawMapRect I call a function in the overlay class which in turn creates the url and opens up a connection. I have already tested my connection class and have confirmed that it does indeed work. I’ve run it in the init functions of overlay and overlayView with success. The urls are good too since I can throw them in a browser and they show the right pngs. I know that canDrawMapRect is running on multiple threads and I only have novice experience with threads.

Here is my connection code,

- (id)initWithStringUrl: (NSString*) url {

    NSLog(@"Test Connect Init URL %@", url);

    self = [super init];
    if (self)
    {
        [self loadURL:[NSURL URLWithString:url]];    
    }

    return self;
}
+ (UIImage*)connectSynchronousWithURL:(NSString*) url {
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];

    NSURLResponse* response = [[NSURLResponse alloc] init];
    NSError* error = [[NSError alloc] init];
    NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    UIImage *image = [UIImage imageWithData: data];

    return image;
}
- (BOOL)loadURL:(NSURL *)inURL {
    NSURLRequest *request = [NSURLRequest requestWithURL:inURL];
    NSURLConnection *conn = [NSURLConnection connectionWithRequest:request delegate:self];

    if (conn) {
        receivedData = [[NSMutableData data] retain];
        NSLog(@"Connection Success");
    } else {
        NSLog(@"Connection Failed");        
        return FALSE;
    }

    return TRUE;
}
- (void)connection:(NSURLConnection *)conn didReceiveResponse:(NSURLResponse *)response {
    NSLog(@"didReceiveResponse");
    [receivedData setLength:0]; 
}
- (void)connection:(NSURLConnection *)conn didReceiveData:(NSData *)data {
    NSLog(@"didReceiveData");
    [receivedData appendData:data];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)conn {
    NSLog(@"Succeeded! Received %d bytes of data", [receivedData length]);
}

Pretty standards stuff. If I run the code in the init of TileOverlayView it’ll work just fine but if I run it in canDrawMapRect then none of the delegate functions get called. I suppose it’s also worth mentioning that the synchronous connection to the server does work in the canDrawMapRect method. I don’t get it at all T_T

Any help would be greatly appreciated. Thank you.

  • 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-23T12:11:20+00:00Added an answer on May 23, 2026 at 12:11 pm

    From the docs about NSURLConnection, this pretty much sums it up.

    Note that these delegate methods will be called on the thread that started the asynchronous load operation for the associated NSURLConnection object.

    Looks like I’ll be needing to use CFRunLoopRun() and CFRunLoopStop(CFRunLoopGetCurrent()); to keep the thread alive. Or find an alternative to making these async calls in the thread.

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

Sidebar

Related Questions

I can run LINQ queries successfully to retrieve data from OData providers. I'm not
I can successfully connect to MySQL from a DOS prompt, but when I try
I have an HBITMAP containing alpha channel data. I can successfully render this using
The code below works insomuch that I can successfully download the directory recursively. But,
I am trying to retrieve data from MySQL for a flash application via PHP,
I'm trying to retrieve data from a JSON object that looks like this: stdClass
I currently successfully use a SQLite database which is populated with data from the
I can successfully include main jquery files in /Scripts, but if my custom test.js
Can anyone explain how I can successfully get my processes communicating? I find the
the title already tells the question: you can successfully call the Print-Method on 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.