Reputation: 426
if let ip = indexPath {
var data: NSManagedObject = myList[ip.row] as NSManagedObject
cell.textLabel?.text = data.valueForKeyPath("item") as String
}
error : "Bound value in a conditional binding must be of Optional type"
I'm using xcode 6.1.1, help please.
I am following this tutorial, [http://www.youtube.com/watch?v=4ymz6i07DRM]
Upvotes: 4
Views: 5233
Reputation: 535989
You are saying:
if let ip = indexPath {
Swift is saying: "Just say let ip = indexPath
, or simply use indexPath
directly. There is no need for the if
(or the curly braces); you don't need a condition here."
The reason is probably that at the time the tutorial you're using was designed, indexPath
was an Optional and needed to be unwrapped. But now it is not an Optional. Apple changes the APIs from time to time.
Upvotes: 13