2

I used sorted method in Swift in Xcode 6.3 as

sorted(UIFont.fontNamesForFamilyName(familyName) as! [String])

I downloaded Xcode 7 beta, it says "sorted in unavailable, call sort on the collection". Any idea what is going wrong?

Anil
  • 53
  • 1
  • 6

1 Answers1

3

Many free functions in swift 1.2 now moved into protocol extensions

(UIFont.fontNamesForFamilyName(familyName) as! [String]).sortInPlace()

In swift book protocol extensions explained like this

Protocols can be extended to provide method and property implementations to conforming types. This allows you to define behavior on protocols themselves, rather than in each type’s individual conformance or in a global function.

mustafa
  • 15,254
  • 10
  • 48
  • 57