I have a problem now. I want to get wikipedia data using wikimeta. I get the data with NSString methode (stringWithContentsOfURL:encoding:error:). But, sometime when the connection wa really slow, i want to cancel the process of getting URL data. But, when i use that methode, i can't to stop the pro开发者_如何学Gocess because we can't detect any touch to button or to UIView. Anyone can help me to resolf my problem? Any way to get data from URL and set it in UITextView so we can look the data in UITextView.
Thanx before. regards.
If I understand your problem correctly, than you can't press buttons because you perform the network connection on the main thread and this causes the UI to freeze.
The correct way is to perform long actions on a background thread, and only perform UI operations on the main thread.
NSURLConnection provides asynchronous methods that allow you to easily perform the actual fetching of data from the server on a background thread. You can read about how to use those methods on NSURLConnection Class Reference
However, the concept of multithreading is extremely important and i would highly recommend that you read a little about it before starting to use asynchronous methods.
You can read a complete guide on the apple documentation
After you learn the basic concepts, i encourage you to read this tutorial. It uses ASIHTTPRequest which is an overkill for beginners, but the explanation of threading concepts there is very very good in my opinion.
精彩评论