I have a path to file contained in an NSString. Is there a method to get its file size?
In Swift 3.x and above you can use:
do {
//return [FileAttributeKey : Any]
let attr = try FileManager.default.attributesOfItem(atPath: filePath)
fileSize = attr[FileAttributeKey.size] as! UInt64
//or you can convert to NSDictionary, then get file size old way as well.
let attrDict: NSDictionary = try FileManager.default.attributesOfItem(atPath: filePath) as NSDictionary
fileSize = dict.fileSize()
} catch {
print("Error: \(error)")
}