divadretlaw / CFileWrapper

πŸ—„ Read files in Swift without Foundation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CFileWrapper

A simple wrapper for File handling in Swift without Foundation

You can read files, save files, append to files and list directories

Usage

if let hello = CFileWrapper.read("HelloWorld.txt") {
  print(hello)
}

Another way to read the file is using a completion handler

CFileWrapper.read("HelloWorld.txt") { text in
	guard let text = text else {
		print("Unable to read file")
		return
	}
	print(text)
}

You can also read by line with a delegate

class MyClass: CFileWrapperDelegate {
  func CFileWrapper(read line: String) {
    print(line)
  }
}

let myClass = MyClass()
CFileWrapper.readw("HelloWorld.txt", delegate: myClass)

About

πŸ—„ Read files in Swift without Foundation


Languages

Language:Swift 100.0%