-3
if let fileObject = NSString(contentsOfFile: strBundle, usedEncoding:Int32?

Every time that I try to work this out, I get more frustrated! Please help me! I am not sure what I need to fill in the "usedEncoding:" parameter.

Here is the error it gives me:

Cannot convert value of type 'Int32?.Type' (aka 'Optional.Type') to expected argument type 'UnsafeMutablePointer?'

Ahmad F
  • 30,560
  • 17
  • 97
  • 143
Jack_Lynch
  • 15
  • 5

1 Answers1

1

Like this:

let f = Bundle.main.url(forResource: "myFile", withExtension: "txt")!
var enc : String.Encoding = .ascii // dummy value
let s = try! String(contentsOf: f, usedEncoding: &enc)

Modify as needed (e.g. use a real try in a do/catch construct etc.); the example code is just to get you going again.

matt
  • 515,959
  • 87
  • 875
  • 1,141