When reading a file, it is important to know the encoding, or so I have learned lately.
NSFilemanager has a method attributesOfItemAtPath:error:, which returns a dictionary.
The keys contain e.g. NSFileSize, but also NSFileExtendedAttributes. NSFileAttributes is a category for NSDictionary.
These
give the same result.
But whatever I try, I can't get to the NSFileExtendedAttributes. d2 in this snippet points to 0x0. d3 will give cause a crash.
NSFileExtendedAttributes {
"com.apple.TextEncoding" = <6d616369 6e746f73 683b30>
}
How can I get the TextEncoding, and how do I interpret its value?
Thanks!
NSFilemanager has a method attributesOfItemAtPath:error:, which returns a dictionary.
The keys contain e.g. NSFileSize, but also NSFileExtendedAttributes. NSFileAttributes is a category for NSDictionary.
These
Code:
[myDictionary valueForKey:NSFileSize];
[myDictionary fileSize];
But whatever I try, I can't get to the NSFileExtendedAttributes. d2 in this snippet points to 0x0. d3 will give cause a crash.
Code:
NSDictionary *dict = [[NSFileManager defaultManager] attributesOfItemAtPath:aPath
error:nil];
int size = [dict fileSize];
for (id key in [dict allKeys]) {
NSLog(@"%@ %@",key, [dict valueForKey:key]);
}
id d2 = [dict valueForKey:@"NSFileExtendedAttributes"];
id d3 = [dict fileExtendedAttributes];
NSFileExtendedAttributes {
"com.apple.TextEncoding" = <6d616369 6e746f73 683b30>
}
How can I get the TextEncoding, and how do I interpret its value?
Thanks!