multithreading - iPhone - is ASIHTTPRequest threadsafe? -
i have method:
-(void)updatesomething { nsautoreleasepool *pool = [[nsautoreleasepool alloc] init]; nsurl *url = [nsurl urlwithstring:@"some url"]; asiformdatarequest *httprequest = [asiformdatarequest requestwithurl:url]; [httprequest startsynchronous]; //some other stuff [pool drain]; }
i call method onapplicationdidfinishlaunching
if call on main thread works fine
[self getmyitems];
but when call on separate thread "program received signal: "exc_bad_access"
[self performselectorinbackground:@selector(getmyitems) withobject:nil];
any idea how resolve issue?
why perform individual requests on separate threads when can use asinetworkqueue?
asinetworkqueue *aqueue = [[asinetworkqueue alloc] init]; [aqueue addoperation:requesttoadd]; [aqueue setdelegate:self]; [aqueue setrequestdidfinishselector:@selector(requestfinished:)]; [aqueue setrequestdidfailselector:@selector(requestfailed:)]; [aqueue setqueuedidfinishselector:@selector(queuefinished:)]; [aqueue go];
asinetworkqueue
subclass of nsoperationqueue
, asi*requests run on separate threads.
Comments
Post a Comment