ZhOCKeR
ZhOCKeR

Reputation: 3

Possible? NSThread request URL by singleton Objective-C iOS

Situation. XMLProxy Class is singleton. XMLRequest Class too.

Normally, when I want to request URL. Example :

XMLProxy *xmlProxy = [XMLProxy sharedInstance];
[xmlProxy tryGetDataWithParameter:example_parameter];

// Method "tryGetDataWithParameter" will call method "requestURL" from XMLRequest Class

// Assume that is [xmlRequest requestURL];

// and XMLProxy Class (XMLProxy delegate) will create xml parser for each "example_parameter" 
type to response xml data receive.

It's no problem.

Question? I want to create visual background process to request URL and I create AutoSending Class that is singleton.

I want to use AutoSending Class to call method "tryGetDataWithParameter" (from XMLProxy class). Example to call : [autoSending start];

-(void)start{ XMLProxy *xmlProxy = [XMLProxy sharedInstance]; [xmlProxy tryetDataWithParameter:example_parameter]; }

Can I use NSThread to call statement "[autoSending start]"; It is the result of a visual Background Process.

Upvotes: 0

Views: 251

Answers (1)

Bryan
Bryan

Reputation: 12200

Rather than try to code all this up by yourself, why not use a library like AFNetworking which is built on top of NSURLConnection, NSOperation, and other standard IOS technologies. You can then use NSOperationQueue to run your request on another thread.

Upvotes: 1

Related Questions