Welcome to the documentation for FileKit! This page will guide you through the features and usage of FileKit, a powerful file management library for iOS.
Table of Contents
Installation
Requirements
– iOS 10.0+
– Swift 4.0+
CocoaPods
To integrate FileKit into your Xcode project using CocoaPods, add the following line to your Podfile
:
“`ruby
pod ‘FileKit’
“`
Then, run the command pod install
.
Carthage
You can also use Carthage to install FileKit. Add the following line to your Cartfile
:
“`ruby
github “FileKit/FileKit”
“`
Then, run the command carthage update
and follow the instructions in the Carthage documentation to add the framework to your project.
Features
- Simple and intuitive API for file management tasks
- Create, read, update, and delete files and directories
- Copy, move, and rename files and directories
- Support for searching and filtering files and directories
- Access file attributes such as size, creation date, and modification date
- File and directory permissions management
Usage
Add FileKit Import Statement
Start by importing FileKit in the relevant source files:
“`swift
import FileKit
“`
Creating a File
To create a new file, use the following example code:
“`swift
let file = File(path: “/path/to/file.txt”)
file.createFile()
“`
Reading a File
To read the contents of a file, you can use the following code:
“`swift
let file = File(path: “/path/to/file.txt”)
if let contents = try? file.readAsString() {
print(contents)
}
“`
Updating a File
To update the contents of a file, you can use the following code:
“`swift
let file = File(path: “/path/to/file.txt”)
try? file.write(“New content”)
“`
Deleting a File
To delete a file, use the delete()
method:
“`swift
let file = File(path: “/path/to/file.txt”)
try? file.delete()
“`
Working with Directories
FileKit provides various methods for working with directories:
dir.createDirectory()
: Create a directory.dir.subdirectories()
: Get an array of subdirectories.dir.files()
: Get an array of contained files.dir.copy(to:)
: Copy the directory to a specified location.dir.move(to:)
: Move the directory to a specified location.dir.rename(to:)
: Rename the directory.
API Reference
For detailed information on the FileKit API, please refer to the FileKit GitHub repository and consult the official documentation.
FAQ
Q: Can I use FileKit with Objective-C?
A: Yes, FileKit is compatible with both Swift and Objective-C projects.
Support
If you encounter any issues or need assistance with FileKit, please reach out to our support team at support@filekit.com. We’re here to help!