繁体   English   中英

可能? 单例Objective-C iOS的NSThread请求URL

[英]Possible? NSThread request URL by singleton Objective-C iOS

情况。 XMLProxy类为单例。 XMLRequest类也是如此。

通常,当我要请求URL时。 范例:

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.

没问题。

题? 我想创建视觉背景过程来请求URL,并创建单例的AutoSending类。

我想使用自动发送类来调用方法“ tryGetDataWithParameter”(来自XMLProxy类)。 调用示例:[自动发送开始];

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

我可以使用NSThread调用语句“ [autoSending start]”吗? 这是视觉背景过程的结果。

与其尝试自己编写所有代码,不如使用AFNetworking之类的库,该库基于NSURLConnectionNSOperation和其他标准IOS技术构建。 然后,您可以使用NSOperationQueue在另一个线程上运行您的请求。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM