1 Reply
      Latest reply on Feb 14, 2017 3:23 PM by eskimo
      norricorp Level 1 Level 1 (0 points)


        am running swift 3.0.2 on Ubuntu.


        when I run the following code

             import Foundation

             let file: NSFileHandle? = NSFileHandle(forReadingAtPath: "data.txt")

        I get an error of

        test.swift:274:11: error: use of undeclared type 'NSFileHandle'

        let file: NSFileHandle? = NSFileHandle(forReadingAtPath: "data.txt")



        NSFileHandle is in the APIs for Foundation though is this true for the Foundation library on Linux?


        What am I doing wrong?




        • Re: use of undeclared type 'NSFileHandle'
          eskimo Apple Staff Apple Staff (13,335 points)

          I don’t run Swift on Linux but it seems like you should be using the Swift Foundation type (FileHandle) rather than the Cocoa Foundation type (NSFileHandle).

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"