0

I have a string that I generate with JSON data from an URL

  NSString *strResult = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

This code is inside viewDidLoad method. I want to release the string before I exit the method to avoid any memory leak, and I do this according to this post.

 [strResult release];

However, xCode does not allow me by giving error: ARC forbids explicit send message of 'release'.

Anybody knows why? I tried to google it but no luck. I am new to iOS programming, and I have tried to google it before I asked. So any help will be appreciated.

Community
  • 1
  • 1
blenzcoffee
  • 851
  • 1
  • 11
  • 35
  • I have a hard time believing this question was Googled before being posted... – nhgrif Nov 16 '13 at 21:10
  • See also [ARC and releasing object created in method](http://stackoverflow.com/q/18727445) and [the Apple docs](https://developer.apple.com/library/mac/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html). – jscs Nov 16 '13 at 21:17
  • I did google it. But I did not find anything that help me understand it. I tried :) – blenzcoffee Nov 16 '13 at 21:18
  • ARC codes the release for you. This is the whole point of ARC. – Hot Licks Nov 17 '13 at 03:18

1 Answers1

0

ARC automatically adds the methods to deallocate objects, at compile time, for you.

Ayan Sengupta
  • 5,238
  • 2
  • 28
  • 40
coder1_7
  • 63
  • 5