iOS App Development Book/Video Series

General Category => FAQs => Topic started by: kjmcneish on September 11, 2015, 08:44:48 PM

Title: Fixing the "pathExtension is unavailable" error in Swift 2.0
Post by: kjmcneish 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 (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 (https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8)