I am trying to check FileAttributeType. Here is my logic to compare:-
let attributes = try fileManager.attributesOfItem(atPath: "/Users/AUSER/Desktop/Downloads")
print(attributes)
if (attributes[FileAttributeKey.type] as AnyObject? == FileAttributeType.typeSymbolicLink ){
print("YESSS \(attributes[FileAttributeKey.type])")
}
Error-> Binary operator '==' cannot be applied to operands of type 'AnyObject?' and 'FileAttributeType'
The (big) mistake is that you cast a very specific type
to a very unspecific type
AnyObject.AnyObjectcannot be compared.Cast the type to
Stringand compare with the rawValue of theFileAttributeTypeSide note: It's highly recommended to use always URLs rather than string paths and get the file attributes directly from the
URL