tags:

views:

569

answers:

2

Here is my code.

- (void) connectionDidFinishLoading: (NSURLConnection *) connection

{
    //Each connection has its own "downloadedData".
    BOOL writeFlag = [downloadedData writeToFile: filePath atomically: YES];
}

I have multiple NSURLConnections at the same time.Each connection corresponds to one download item.App crashes when multiple downloads finish at the same time.Is this method thread-safe?

It says:

_serverConnectionDiedNotification. Info -- notification=NSConcreteNotification 0x11d90470{name = AVController_ServerConnectionDiedNotification; object = <AVController: 0x11d855a0>},
 AVController = <AVController: 0x11d855a0>,currentTime = 0.00

Program received signal:  “0”.
warning: check_safe_call: could not restore current frame

THANKS!

+1  A: 

I assume downloadedData is not shared between the different requests? Because that would probably not be a good idea.

I use the ASI-HTTPRequest library for my http request needs. It's easy to do things like asynchronous requests right. You might find it useful.

WardB
No,each connection has its own "downloadedData".Thanks for the tip for ASI-HTTPRequest library,though.
aquaibm
+1  A: 

OK,I figure out myself.Besides downloadedData, I have a few arrays and dictionarys pair with each unique connection. Seems like I didn't take care of those collections carefully enough. When I clear this mess up,phew,problems are gone!

aquaibm