geforce
geforce

Reputation: 2643

iOS5 using ARC: Implicit conversion of int to NSDictionary

i´m using ARC to update my old project. I have a "Filehelper" class in which i use c-functions e.g. for methods i need in almost every projects. (eg.load plist, etc..)

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;
    }
}

I get this error:

*error: Automatic Reference Counting Issue: Implicit conversion of 'int' to 'NSDictionary ' is disallowed with ARC

Any ideas how to fix it to use it with iOS 5? I´ve read something that i need to use (__bridge NSDictionary*), but that didn´t help.

PS. What´s your workflow for classes which you already need? Use C-functions, too?= What´s the best way?

Upvotes: 0

Views: 923

Answers (1)

Rob Napier
Rob Napier

Reputation: 299355

The most likely problem here is that you forgot to #include your header file. I bet there are further warnings that you're ignoring, particularly one that says something like "unknown signature for getDictionaryFromPlistWithName, assuming it returns int". Read through your warnings and never ignore them (I strongly recommend -Werror for all ObjC projects).

Upvotes: 1

Related Questions