Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

limit log file size swift

let fileUrl: URL
print("file size = (fileUrl.fileSize), (fileUrl.fileSizeString)")
Comment

limit log file size swift

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
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: swift struct field default value 
Swift :: remove back button swift 
Swift :: disable dark mode swift 
Swift :: swift play audio stream from url 
Swift :: swift wait 5 seconds 
Swift :: Return multiple value of different data types swift 
Swift :: swift constraint center vertically 
Swift :: swift uiview gradient 
Swift :: set color for uibutton programmatically swift 
Swift :: swift convert decimal to string 
Swift :: rotate image animated swift 
Swift :: swift core data sort by date 
Swift :: Thread 1: breakpoint 1.1 
Swift :: how to style textfield swiftui 
Swift :: how to set the spacing of a collection view swift 
Swift :: swiftui textfield height 
Swift :: activity indicator swiftui 
Swift :: swift repeating array 
Swift :: swift convert string to int 
Swift :: create button with icon swift 
Swift :: timer in swift stack overflow 
Swift :: swift extension Array with specific element type 
Swift :: get last element of array swift 
Swift :: Convert JSON to Data 
Swift :: Swift Omit Argument Labels 
Swift :: Customize indicator view iOS swift 
Swift :: Swift Named Tuple 
Swift :: enums With Raw Values Swift 
Swift :: Autoclosure Swift 
Swift :: image copy swift extension 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =