2013-08-02 6 views
0

이 오류는 대상 작동 시스템에서 지원하지 않는 NSByteCountFormatter와 관련 될 수 있음을 읽었습니다.NSByteCountFormatter 표시 안 함 @interface

이 클래스는 10.8 (Mountain Lion) 버전에서 지원됩니다. 그래서 "Deploy Target"프로젝트를 10.6에서 10.8로 변경했지만이 오류가 발생했습니다.

make clean, reboot, nothing .. 시도했습니다. 내가 뭔가를 잃어 버렸나요?

NSByteCountFormatter *sizeFormatter = [[NSByteCountFormatter alloc] init]; 
[sizeFormatter includesUnit:NO]; 

//fileSizeMb is a NSString 
fileSizeMb = [sizeFormatter stringFromByteCount:[fileSize longLongValue] countStyle:NSByteCountFormatterCountStyleFile]; 

오류 : 'NSByteCountFormatter'에 대한 @interface가 선택 'stringFromByteCount : countStyle :'선언하지

어떤 생각을?

답변

1

+ stringFromByteCount:countStyle:클래스 방법입니다. 따라서 사용하실 수 있습니다

fileSizeMb = [NSByteCountFormatter stringFromByteCount:[fileSize longLongValue] countStyle:NSByteCountFormatterCountStyleFile]; 

하지만 원하는 countStyle이 없습니다. 또는 내가이 `attribs의 = [: atPath 오류 : 파일 관리자 attributesOfItemAtPath 및 오류]를 사용하여 간단하게 해결 순간 어쨌든,이 프로젝트를 완료 할 때 나는 당신의 제안을하려고합니다

NSByteCountFormatter *sizeFormatter = [[NSByteCountFormatter alloc] init]; 
[sizeFormatter includesUnit:NO]; 
sizeFormatter.countStyle = NSByteCountFormatterCountStyleFile; 

//fileSizeMb is a NSString 
fileSizeMb = [sizeFormatter stringFromByteCount:[fileSize longLongValue]]; 
+0

에 코드를 변경; fileSizeMb = [[attribs objectForKey : @ "NSFileSize"] doubleValue]/1000/1000; ' 어쨌든 해결책 주셔서 감사합니다. – Benz