[swift-dev] Linux Swift API
Roman Pastushkov
xnucleargeminix at aol.com
Tue Jan 31 09:51:45 CST 2017
Hello everyone! Now i am trying (newbie) on Ubuntu Swift 3. I am trying to Read String from File Using FileHandle
import Foundation
let filemgr = FileManager.default
let filepath1 = "/home/roman/test"
let file: FileHandle? = FileHandle(forReadingAtPath: filepath1)
if file == nil {
print("File open failed")
} else {
let databuffer = file?.readDataToEndOfFile
let String1 = String(databuffer, encoding: String.Encoding.utf8)
file?.closeFile()
print(String1)
}
But get error from compiler
/home/roman/swift/Sources/main.swift:11:19: error: 'init' has been renamed to 'init(describing:)'
let String1 = String(databuffer, encoding: String.Encoding.utf8)
^
Swift.String:21:12: note: 'init' has been explicitly marked unavailable here
public init<T>(_: T)
^
<unknown>:0: error: build had 1 command failures
error: exit(1): /home/roman/swift-3.0.2-RELEASE-ubuntu16.04/usr/bin/swift-build-tool -f /home/roman/swift/.build/debug.yaml
Why it talking about init? when i use String
Roman Pastushkov
xnucleargeminix at aol.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20170131/ce62ec42/attachment.html>
More information about the swift-dev
mailing list