저는 ARC를 사용하여 기존 프로젝트를 업데이트합니다. 나는 C 함수를 사용하는 "Filehelper"클래스를 가지고 있습니다. 내가 거의 모든 프로젝트에서 필요한 방법. (eg.load의 PLIST, 등)ARC를 사용하는 iOS5 : int의 NSDictionary 로의 암시 적 변환
의 ViewController
NSDictionary* dictionary = getDictionaryFromPlistWithName(@"TestFile", @"plist");
Filehelper.m
#pragma Returns content of plist as NSDictionary
NSDictionary* getDictionaryFromPlistWithName(NSString* fileName, NSString* pathExtension) {
NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:pathExtension];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:path];
if(fileExists){
NSDictionary* dictionary = [NSDictionary dictionaryWithContentsOfFile:path];
return dictionary;
}
else{
[NSException raise:@"File not found" format:@"path %@", path];
return nil;
}
}
이 오류 얻을 :
*error: Automatic Reference Counting Issue: Implicit conversion of 'int' to 'NSDictionary ' is disallowed with ARC
어떤 아이디어가 그것을 해결하는 방법을 iOS 5와 함께 사용 하시겠습니까? 나는 (__bridge NSDictionary *) 사용할 필요가있는 것을 읽었지만 도움이되지 못했습니다.
추신. 이미 필요한 수업에는 어떤 워크 플로가 있습니까? C 함수도 사용합니까? = 가장 좋은 방법은 무엇입니까?
어떤 줄에서 오류가 발생합니까? – Caleb
왜'- (NSDictionary *) dictionaryFromPlistWithName : (NSString *)과 같은 Objective-C 메소드를 선언하는 대신에 NSDictionary * getDictionaryFromPlistWithName (NSString * fileName, NSString * pathExtension) 함수의 C 스타일 선언문을 사용하고 있습니까? *) pathExtension'? –
@AndreyZ. 어쩌면 그가 이것을 C 함수로 만들고 특정 클래스에 꼭 붙기를 원하지 않기 때문에? –