-4

I am building ios app when I encountered a problem. It says ARC forbids explicit message send 'retain'. Here is my code that give me error.

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

What should I do here? My ARC is turn on and I want it to stay on so what will I do.

2 Answers2

5

Just remove retain and compiler will ensure that memory management is correct automatically:

filePath = [NSString stringWithFormat:@"%@", [[NSBundle mainBundle] resourcePath]];
Vladimir
  • 169,112
  • 36
  • 383
  • 312
1
filePath = [NSString stringWithFormat:@"%@", 
           [[NSBundle mainBundle] resourcePath]];
David
  • 15,335
  • 22
  • 54
  • 65
Marc
  • 5,737
  • 5
  • 27
  • 52