Author Topic: Fixing the "pathExtension is unavailable" error in Swift 2.0  (Read 3265 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
Fixing the "pathExtension is unavailable" error in Swift 2.0
« on: September 11, 2015, 08:44:48 PM »
In Swift 2.0, the pathExtension property has been removed from the String class. You can use NSURL's pathExtension instead, but if you want to keep this property on the String class, just use this extension:

Code: [Select]
var pathExtension: String {
       
   get {
      return (self as NSString).pathExtension
   }
}

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8
« Last Edit: November 15, 2015, 10:13:04 AM by kjmcneish »