I had this code with a completion handler working in Xcode 6 beta 4 that no longer works in Xcode 6 beta 5.
dropsToRemove.bridgeToObjectiveC().makeObjectsPer
Someone from Apple has stated that those bridgeToObjectiveC
and bridgeFromObjectiveC
functions are meant as private functions, i.e. for Apple internal use only, and that they would go away.
I will try to find the link to that statement in the developer forums, if you happen to be in the developer program.
The bridgeToObjectiveC
and bridgeFromObjectiveC
functions are not available in Xcode 6.0 beta 5. Instead, cast to/from the appropriate Foundation type when you need to use that type's API on a Swift object. For example:
var arr = ["One", "Two"]
(arr as NSArray).indexOfObject("One")
Apple has warned against (or explicitly made unavailable) using performSelector
and related methods since the first Swift beta. Presumably any such API that were still available before beta 5 were unintentionally so.
As the question you cited notes, you can use map
to call a function/method on every element of an array. You can also use filter
, find
or a for
-in
loop, or after casting to NSArray
, one of the enumerateObjects
methods. Note that many consider it bad style to use the functional-programming constructs (map
, filter
, reduce
, find
) for tasks that aren't "functional" -- that is, to run code that has side effects. So a for
-in
loop might be the cleanest way to do what you're after.