Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios ARC禁止显式消息发送';保留';_Ios_Automatic Ref Counting - Fatal编程技术网

Ios ARC禁止显式消息发送';保留';

Ios ARC禁止显式消息发送';保留';,ios,automatic-ref-counting,Ios,Automatic Ref Counting,当我遇到问题时,我正在构建ios应用程序。它说ARC禁止显式消息发送“保留”。这是我的代码,给我错误 filePath= [[NSString stringWithFormat:@"%@", [[NSBundle mainBundle] resourcePath]] retain]; 我在这里该怎么办?我的ARC已打开,我希望它保持打开状态,那么我该怎么办。只需删除retain,编译器将自动确保内存管理正确: filePath = [NSString stringWithFormat:

当我遇到问题时,我正在构建ios应用程序。它说ARC禁止显式消息发送“保留”。这是我的代码,给我错误

    filePath= [[NSString stringWithFormat:@"%@", [[NSBundle mainBundle] resourcePath]] retain];

我在这里该怎么办?我的ARC已打开,我希望它保持打开状态,那么我该怎么办。

只需删除retain,编译器将自动确保内存管理正确:

filePath = [NSString stringWithFormat:@"%@", 
           [[NSBundle mainBundle] resourcePath]];
filePath = [NSString stringWithFormat:@"%@", [[NSBundle mainBundle] resourcePath]];

你知道ARC是什么吗?而且也被否决了,因为相关问题中有多个链接已经回答了这个问题。我不理解ARC,这就是我为什么要问这个问题。我对ios的人不熟悉。