2012-11-08 29 views
0

我已经成立了一个UILabel,后者从parse.com其内容。一切正常,直到我启用飞行模式。在其中加载标签认为我会很长加载时间和控制台给我的代码:很长的加载与解析的NSString

2012-11-08 21:07:41.179 My App[5275:907] Warning: A long-running Parse operation is being executed on the main thread. 
Break on warnParseOperationOnMainThread() to debug. 
2012-11-08 21:07:41.231 My App[5275:907] Error: Error Domain=NSURLErrorDomain Code=-1009 "Es besteht anscheinend keine Verbindung zum Internet." UserInfo=0x1e5c2f00 {NSErrorFailingURLStringKey=https://api.parse.com/2/find, NSErrorFailingURLKey=https://api.parse.com/2/find, NSLocalizedDescription=Es besteht anscheinend keine Verbindung zum Internet., NSUnderlyingError=0x1e5c1d70 "Es besteht anscheinend keine Verbindung zum Internet."} (Code: 100, Version: 1.1.14) 
2012-11-08 21:07:41.232 My App[5275:907] Network connection failed. Making attempt 2 after sleeping for 1.287663 seconds. 
2012-11-08 21:07:42.582 My App[5275:907] Error: Error Domain=NSURLErrorDomain Code=-1009 "Es besteht anscheinend keine Verbindung zum Internet." UserInfo=0x1e5c6f00 {NSErrorFailingURLStringKey=https://api.parse.com/2/find, NSErrorFailingURLKey=https://api.parse.com/2/find, NSLocalizedDescription=Es besteht anscheinend keine Verbindung zum Internet., NSUnderlyingError=0x1e5c6f40 "Es besteht anscheinend keine Verbindung zum Internet."} (Code: 100, Version: 1.1.14) 
2012-11-08 21:07:42.583 My App[5275:907] Network connection failed. Making attempt 3 after sleeping for 2.575326 seconds. 
2012-11-08 21:07:45.215 My App[5275:907] Error: Error Domain=NSURLErrorDomain Code=-1009 "Es besteht anscheinend keine Verbindung zum Internet." UserInfo=0x1f88bd90 {NSErrorFailingURLStringKey=https://api.parse.com/2/find, NSErrorFailingURLKey=https://api.parse.com/2/find, NSLocalizedDescription=Es besteht anscheinend keine Verbindung zum Internet., NSUnderlyingError=0x1f88c840 "Es besteht anscheinend keine Verbindung zum Internet."} (Code: 100, Version: 1.1.14) 
2012-11-08 21:07:45.216 My App[5275:907] Network connection failed. Making attempt 4 after sleeping for 5.150652 seconds. 
2012-11-08 21:07:50.383 My App[5275:907] Error: Error Domain=NSURLErrorDomain Code=-1009 "Es besteht anscheinend keine Verbindung zum Internet." UserInfo=0x1f88c310 {NSErrorFailingURLStringKey=https://api.parse.com/2/find, NSErrorFailingURLKey=https://api.parse.com/2/find, NSLocalizedDescription=Es besteht anscheinend keine Verbindung zum Internet., NSUnderlyingError=0x1f88b4a0 "Es besteht anscheinend keine Verbindung zum Internet."} (Code: 100, Version: 1.1.14) 
2012-11-08 21:07:50.384 My App[5275:907] Network connection failed. Making attempt 5 after sleeping for 10.301305 seconds. 
2012-11-08 21:08:00.743 My App[5275:907] Error: Error Domain=NSURLErrorDomain Code=-1009 "Es besteht anscheinend keine Verbindung zum Internet." UserInfo=0x1e5c8160 {NSErrorFailingURLStringKey=https://api.parse.com/2/find, NSErrorFailingURLKey=https://api.parse.com/2/find, NSLocalizedDescription=Es besteht anscheinend keine Verbindung zum Internet., NSUnderlyingError=0x1f88e450 "Es besteht anscheinend keine Verbindung zum Internet."} (Code: 100, Version: 1.1.14) 

“ES besteht anscheinend keine Verbindung的Zum互联网”意味着那里有没有互联网连接。

有没有办法解决这个问题?

感谢

回答

1

不要做在主线程联网 - 永远:)

dispatch_async块,仅设置标签的主线程上的文字。

- (void)doLongOperation:(id)someParam withCompletionHandler:(void (^)(NSString *newLabelString))completionHandler { 
    dispatch_async(dispatch_get_global_queue(0,0), ^{ 
     NSString *labelString = /*do call to parse OR any other long running operation*/ 

     if (completionHandler) { 
      dispatch_async(dispatch_get_main_queue(), ^{ 
      completionHandler(labelString); 
     }); 
    }); 
} 

// now in your main app call it 
[self doLongOperation:nil /*we dont need anything here*/ withCompletionHandler:^(NSString *newLabelString) { 
    self.label.text = newLabelString; 
}]; 
+0

请什么?对不起,我是一个新手。你能告诉我如何解决这个问题吗? – MasterRazer

+0

对不起,是有点冲.. illl编辑我的答案 –

+0

哦,没关系,但我发现别的东西来解决重复错误 – MasterRazer