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

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -