我試圖在我的應用程序中包含一個方法,如determines the size of a file如file.txt,file.app,file.png等。我對如何做到這一點有一般的想法,試過以下,但我的應用程序,因爲在年底的NSLog功能的崩潰:Objective-C,以編程方式確定文件大小
NSString *yourPath = @"path/to/file";
NSFileManager *man = [[NSFileManager alloc] init];
NSDictionary *attrs = [man attributesOfItemAtPath: yourPath error: NULL];
UInt32 result = [attrs fileSize];
NSLog(@"Size: @%", result);
如果您發佈了「某些原因」,我們實際上可以提供幫助。 – 2012-08-31 18:10:02
是的,有什麼錯誤? *查看*> *調試區*> *激活控制檯* – woz
您可以發佈您的答案並將其標記爲已回答嗎? – woz