Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

grr SWIFT 3 broke my app

jarvjarv Posts: 203Registered Users @ @
So I was using SWIFT 2 with SwiftyJSON and then I updated to SWIFT 3 and my app is now broken

can someone please help me with my function in Swift 2 which is now broken, how can I make this work in SWIFT 3? without using SwiftyJSON
func parseJSONtowns() {
        //selectedTown = "Worthing"
        let url = URL(string: "http://www.mypubspace.com/json/listtowns.php";)
        let jsonData = try? Data(contentsOf: url!)
        let readableJSON = JSON(data: jsonData!, options: JSONSerialization.ReadingOptions.mutableContainers, error: nil)
        
        
        for (_,object):(String, JSON) in readableJSON {
            let town = object["town"].string as String!
            townsArray.append(town)
            
            NumberOfRows = townsArray.count
        }
        NSLog("\(townsArray)")
        NSLog("There are so many towns: \(NumberOfRows)")
        
    }

Replies

Sign In or Register to comment.