iOS警告:函数\'pathInDocumentDirectory\'的隐式声明

问题描述

|| 在尝试开发我的第一个iPhone应用程序时,对于以下代码行,我收到了\“ pathInDocumentDirectory \'函数的隐式声明”警告:
NSString *imagePath = pathInDocumentDirectory(s);
奇怪的是,我找不到关于该怎么办的任何好的信息。有人知道如何消除警告吗?谢谢!     

解决方法

如果那是一个内联函数,请将声明移到实现文件的顶部(在任何使用它之前)。 如果是您编写的方法,则应为Objective-C方法...
-(NSString *)pathInDocumentDirectory:(NSString *)value {

}
那你用...
NSString *path = [self pathInDocumentsDirectory:aValue];
不要忘记在实现文件的标头或私有类别中声明该方法。     ,确保已导入或包含包含pathInDocumentDirectory函数的头文件。 要么 如果pathInDocumentDirectory函数位于同一文件中,则将其放在您使用的函数之前。或者首先声明pathInDocumentDirectory。     

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...