![](/img/trans.png)
[英]Implicit conversion of 'int' to 'NSDictionary *' is disallowed with ARC
[英]iOS5 using ARC: Implicit conversion of int to NSDictionary
我正在使用ARC更新我的旧项目。 我有一个“ Filehelper”类,在其中使用c函数,例如,几乎在每个项目中都需要使用的方法。 (例如,加载plist等。)
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;
}
}
我收到此错误:
*错误:自动引用计数问题: ARC不允许将'int'隐式转换为'NSDictionary '
有什么想法如何修复以使其在iOS 5上使用吗? 我已经读了一些我需要使用的东西(__bridge NSDictionary *),但这没有帮助。
PS。 您已经需要的课程的工作流程是什么? 是否也使用C函数?=最佳方法是什么?
这里最可能的问题是您忘记了#include
头文件。 我敢打赌,还有其他警告可能会被您忽略,特别是警告说“ getDictionaryFromPlistWithName的未知签名,假设它返回int”。 通读您的警告,切勿忽略它们(我强烈建议所有ObjC项目使用-Werror)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.