limit log file size swift
let fileUrl: URL
print("file size = \(fileUrl.fileSize), \(fileUrl.fileSizeString)")
extension URL {
var attributes: [FileAttributeKey : Any]? {
do {
return try FileManager.default.attributesOfItem(atPath: path)
} catch let error as NSError {
print("FileAttribute error: \(error)")
}
return nil
}
var fileSize: UInt64 {
return attributes?[.size] as? UInt64 ?? UInt64(0)
}
var fileSizeString: String {
return ByteCountFormatter.string(fromByteCount: Int64(fileSize), countStyle: .file)
}
var creationDate: Date? {
return attributes?[.creationDate] as? Date
}
}
Also in Swift:
- swift uitextfield only numbers keyboard lock programmatically
- swift ns_enum generic name
- Split a String into an array in Swift
- uilabel font size swift
- use alamofire to login in swift 5
- swiftui background color
- swift uitableview insert cell
- print things in swift
- swift list
- show alert swiftui
- how to set the center in view in swift
- swift wait 5 seconds
- Get the length of a String swift
- .next() enum swift
- swift show title on navigation bar programmatically
- xcode how to know which textfield is selected
- verilog monitor
- displaying button title swift stackoverflow
- convert string to int swift
- swift get day from available string
- hide bottom tab bar swift
- IOS create UIAlertViewController programmatically
- how to screen record swift stackoverflow
- swift switch