Skip to content

Commit

Permalink
Fixes to compile in swift 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniciusMiana committed Apr 13, 2015
1 parent 604c943 commit 98e9769
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions SwiftPlaces/JSONService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class JSONService
{
func success(
closure: (json: AnyObject) -> (), // Array or dictionary
queue: NSOperationQueue? = nil) // Background queue by default
queue: NSOperationQueue? = nil ) // Background queue by default
-> ErrorHandler
{
self.closure = closure
Expand All @@ -54,7 +54,7 @@ class JSONService
{
func failure(
closure: (statusCode: Int, error: NSError?) -> (),
queue: NSOperationQueue? = nil) // Background queue by default
queue: NSOperationQueue? ) // Background queue by default
{
self.closure = closure
self.queue = queue
Expand Down
2 changes: 1 addition & 1 deletion SwiftPlaces/Place.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Place : NSObject, Equatable
// Used by Foundation collections, such as NSSet.
override func isEqual(object: AnyObject!) -> Bool
{
return self == object as Place
return self == object as! Place
}
}

Expand Down
3 changes: 2 additions & 1 deletion SwiftPlaces/PlaceViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class PlaceViewController: UIViewController
url = URLFactory.weatherAtLatitude(lat, longitude: lng)
JSONService
.GET(url)
.success{json in {self.makeWeather(json)} ~> {self.showWeather($0)}}
.success({json in {
self.makeWeather(json)} ~> {self.showWeather($0)}})
.failure(onFailure, queue: NSOperationQueue.mainQueue())
}

Expand Down
10 changes: 5 additions & 5 deletions SwiftPlaces/SearchViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ class SearchViewController: UIViewController, UITableViewDelegate, UISearchBarDe
// Show an "empty view" on the right-hand side, only on an iPad.
if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad
{
let emptyVC = storyboard!.instantiateViewControllerWithIdentifier("EmptyPlaceViewController") as UIViewController
let emptyVC = storyboard!.instantiateViewControllerWithIdentifier("EmptyPlaceViewController") as! UIViewController
splitViewController!.showDetailViewController(emptyVC, sender: self)
}
}

// MARK: - UITableViewDelegate

func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!)
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
let placeVC = storyboard!.instantiateViewControllerWithIdentifier("PlaceViewController") as PlaceViewController
let placeVC = storyboard!.instantiateViewControllerWithIdentifier("PlaceViewController") as! PlaceViewController
placeVC.place = dataSource.places[indexPath.row]
showDetailViewController(placeVC, sender: self)
}

// MARK: - UISearchBarDelegate

// Called when the keyboard search button is pressed.
func searchBarSearchButtonClicked(searchBar: UISearchBar!)
func searchBarSearchButtonClicked(searchBar: UISearchBar)
{
let input = searchBar.text?
.stringByTrimmingCharactersInSet(
Expand Down Expand Up @@ -74,7 +74,7 @@ class SearchViewController: UIViewController, UITableViewDelegate, UISearchBarDe
let url = URLFactory.searchWithPostalCode(postalCode)
JSONService
.GET(url)
.success{json in {self.makePlaces(json)} ~> {self.showPlaces($0)}}
.success({json in {self.makePlaces(json)} ~> {self.showPlaces($0)}})
.failure(onFailure, queue: NSOperationQueue.mainQueue())
}
return valid
Expand Down
2 changes: 1 addition & 1 deletion SwiftPlaces/UISearchBar+ErrorMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extension UISearchBar
setEnabled(false, image: errorImage, text: errorMessage)
delay(lingerDuration)
{
let perCharacter = self.eraseDuration / Double(self.text.utf16Count)
let perCharacter = self.eraseDuration / Double(count(self.text))
self.eraseErrorMessageWithStepwiseDuration(perCharacter)
{
self.setEnabled(true, image: startImage, text: "")
Expand Down

0 comments on commit 98e9769

Please sign in to comment.