jeudi 7 juillet 2016

Swift 2.0 conditional assignment and syntax

Good afternoonz! The following code works: (where someArray.objectForKey("someKey") is of type NSNumber)

var someInt:Int = 123

if(someArray.objectForKey("someKey") != nil) {
    someInt = someArray.objectForKey("someKey")!.integerValue
}

So that works and does what I need it to do BUT I am almost 450% sure this isn't the way it's supposed to be done in Swift.

I'm looking for a more elegant solution to the above code.

Please and thank you!!!

Aucun commentaire:

Enregistrer un commentaire