Question

I am creating a tabbar application. One of the tabs is for an rss feed, which is a navigation application. but when i click the tab bat button, it is taking a while to load the view of that tab. It is because the application is waiting for the feed to be loaded from the server. Is there any way to load the view before the loading of that feed takes place. As of now, i'm giving the request in the viewDidLoad method. Thats what is creating the problem. To which part shall i move the code so that the view is loaded instantaneously when clicking the tabbar button.

Was it helpful?

Solution

I recommend this great article on this subject on iCodeBlog, it's a very elegant way of doing this. If you submit your rss feed loading as an NSOperation, it will take place nicely in the background without blocking your main thread.

OTHER TIPS

use:

[self performSelector:@selector(performRSS:) withObject:<nil afterDelay:0.3f];

or

[NSThread detachNewThreadSelector:@selector(performRSS:) toTarget:self withObject:nil];

and place RSS feed related code in a separate function named "performRSS".

I also think that the problem is more that you don't use the HTTP request asyncronously (as Apple recommends). See this document. http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

It worked for me in my applications.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top