As an alternative to using reduce directly on the zz array, you could apply an attempted Double initialization (by the failable init?(_:String) initializer of Double) of the a1 member of each element of zz within a flatMap call on zz, whereafter you apply reduce to sum the elements which were successfully initialized as Double instances.
struct Custom {
let a1: String
init(_ a1: String) { self.a1 = a1 }
}
let zz: [Custom] = [Custom("1.4"), Custom("z"), Custom("3.1")]
let sumOfValids = zz.lazy.flatMap{ Double($0.a1) }.reduce(0, +) // 4.5
For the last part (if you really want this)
"I would like to add the a1 property of all the elements in the array
and return an NSNumber value".
you can simply make use of the appropriate NSNumber by Double initializer.
Finally, note that none of the above performs attempted casting from String to Double, but attempted initialization of a Double by a String value, making use of the failable by String initializer blueprinted in LosslessStringConvertible, to which Double conforms.
"Since the value a1 is a String, I will also have to cast it into a
Double on the go too".