Wednesday, July 16, 2014

RSNetworking – A network library written in Swift: Update 1


A few days ago I wrote about a network library that I am writing in Swift, you can see the post here.  Tonight I committed my first update to the library.  This update adds an extension to the UIImageView class and a function to check if a host is reachable.  The GitHub repository is here:  https://github.com/hoffmanjon/RSNetworking

The UIImageView extensions adds two functions to asynchronously download an image from a URL.   These functions are:
  • setImageForURL(url: NSString, placeHolder: UIImage):  Sets the image in the UIImageView to the placeHolder image and then asynchronously downloads the image from the URL.  Once the image is downloaded it then replaces the placeHolder image with the image downloaded.
  • setImageForURL(url: NSString):  Asynchronously downloads the image from the URL.  Once the image is downloaded, it sets the image of the UIImageView to the downloaded image. 

I also added a function to check if a host is reachable or not.  This function is:

  • isHostReachable(hostname: NSString) -> Bool:  Returns true if the host is reachable or false if it is not.

A second sample project was added that shows how to use the UIImageView extension and the isHostReachable function.

I will hopefully be able to update this library on a regular basis.  If anyone would like to contribute to the library, please do so.  Also any suggestions on what you would like to see in the library would also be helpful. 

1 comment: