In the last example on p. 177, there is this line:
if let compoundPredicate = NSPredicate(format: formatString, someName) {
...
}
-
The NSPredicate docs do not list any such initializer for Swift.
-
In a playground, this code:
[code]let formatString = “name like[c] %@ and raise > 0.0”
var someName = “Joe”
if let predicate = NSPredicate(format: formatString, someName) {
println(“hello”)
}[/code]
produces an error:
I interpret that to mean that the undocumented initializer does not return an Optional type, so using if-let is inappropriate.
And in fact, when I get rid of the if-let:
[code]let formatString = “name like[c] %@ and raise > 0.0”
var someName = “Joe”
let predicate = NSPredicate(format: formatString, someName) {
println(“hello”)
}
[/code]
I get the error:
Anyone know why the Xcode designers made error messages unselectable and uncopyable?