use of undeclared type 'NSFileHandle'

Hi,

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?


Regards,

John

Replies

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"