2012-02-06 3 views
0

저는 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 함수도 사용합니까? = 가장 좋은 방법은 무엇입니까?

+1

어떤 줄에서 오류가 발생합니까? – Caleb

+0

왜'- (NSDictionary *) dictionaryFromPlistWithName : (NSString *)과 같은 Objective-C 메소드를 선언하는 대신에 NSDictionary * getDictionaryFromPlistWithName (NSString * fileName, NSString * pathExtension) 함수의 C 스타일 선언문을 사용하고 있습니까? *) pathExtension'? –

+0

@AndreyZ. 어쩌면 그가 이것을 C 함수로 만들고 특정 클래스에 꼭 붙기를 원하지 않기 때문에? –

답변

1

가장 큰 문제는 여기에서 #include 헤더 파일을 깜빡 한 것입니다. 나는 당신이 무시하고 있다는 경고, 특히 "int를 반환한다고 가정하고"getDictionaryFromPlistWithName에 대한 "unknown signature"와 같은 것을 말하는 경고가있을 것입니다. 경고를 읽고 무시하지 마십시오 (모든 ObjC 프로젝트에 대해 Werror 권장).

+0

고마워요, 롭. 그러나 아무 경고도 없다. 나는 그들을 무시하지 않는다. 하지만 당신의 힌트를 주셔서 감사합니다. – geforce

+0

하지만 이제는 작동합니다. 아마도 당신이 말한 것처럼 헤더를 포함하는 것을 잊어 버린 것일 수도 있습니다. 내 잘못;) 모두에게 고마워. – geforce