-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
  • 170,431
  • 36
  • 387
  • 313
1
filePath = [NSString stringWithFormat:@"%@", 
           [[NSBundle mainBundle] resourcePath]];
David
  • 15,894
  • 22
  • 55
  • 66
Marc
  • 6,051
  • 5
  • 26
  • 56