uchicago-mobi / 2015-Winter-Forum

8 stars 1 forks source link

Network Activity and Use of Singleton #135

Closed mattmeier closed 9 years ago

mattmeier commented 9 years ago

Should we check the network availability only when we download the RSS feed or also every single time we load a URL, in particular of the webView? Also, I guess we have to call the Singleton getWeatherForURL method each time before we load a webView, right?

narvemp commented 9 years ago

You shouldn't need to call the singleton method to load webview since it has a built in 'load request' method. This method simply initiates the load the process and doesn't block the main thread.

tabinks commented 9 years ago

You should integrate the networking check so that it is checked before every network attempt. Something like:


getDataForURL(..) {
   if (![self isNetworkAvailable]) return;

  NSURLSession....
}

- (BOOL)isNetworkAvailable {
 if (...) { 
   return YES;
 } esle {
  UIAlertView *alert = ....
  return NO;
}

For this assignment, you can limit the networking to you own networking calls (i.e. you don't need to check the network before loading the web view). You can assume that if you can get the RSS data that the web view will be able load.

narvemp commented 9 years ago

UIWebView has several delegate methods that would allow you to determine network activity and also determine if a webpage loaded properly.

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebViewDelegate_Protocol/index.html#//apple_ref/occ/intfm/UIWebViewDelegate/webViewDidFinishLoad:

mattmeier commented 9 years ago

Sorry, if this is a stupid question, but I can't figure out how to actually call the

function from Andrew's gist in practice, i.e. how the syntax and some example parameters would look like in a call to it (I get it for the other non-block statements of the singleton).