0

Hmm the usual Swift upgrades rewrites required. My venerable path command no longer works saying "stringByAppendingPathCompnent is unavailable"

return NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)[0].stringByAppendingPathComponent(fileName)

If I use URLByAppendingComponent as instructed

return NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)[0].URLByAppendingPathComponent(fileName)

I am told that value of type String has no member URLByAppointmentPathComponent

How should I go about resolving this?

Edward Hasted
  • 3,201
  • 8
  • 30
  • 48
  • I went through that question before I posted mine and couldn't work out how it answered my issue. This could easily be my lack of experience but am finding the Swift 2.0 change instructions convoluted. Appreciated, – Edward Hasted Sep 19 '15 at 11:26
  • Cast the String to NSString. – Darko Sep 19 '15 at 12:14

1 Answers1

1

Instead of that you can try this:

return try!  NSFileManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: true).URLByAppendingPathComponent(fileName).path!
Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165