PDA

View Full Version : [NSString release] in XCode 4.2??




Fritzables
Mar 23, 2012, 02:01 AM
Hi All,

I have heard a rumor that XCode 4 does a better job of Memory Management compared to former versions.

If I declare a string like:

NSString *aString = [NSString alloc] init];

do I still need to:

[aString release];

or will it be looked after by XCode4 ??

Pete



GorillaPaws
Mar 23, 2012, 02:40 AM
You're missing an opening bracket. I suspect you're thinking of ARC or Automated Reference Counting. Here's a link to the documentation (http://clang.llvm.org/docs/AutomaticReferenceCounting.html).

gnasher729
Mar 23, 2012, 02:44 AM
Hi All,

I have heard a rumor that XCode 4 does a better job of Memory Management compared to former versions.

If I declare a string like:

NSString *aString = [NSString alloc] init];

do I still need to:

[aString release];

or will it be looked after by XCode4 ??

Pete

Read the documentation for ARC. The compiler will do lots of things for you if you ask it to, but you still need to know how memory management works.

thundersteele
Mar 23, 2012, 03:23 PM
You're missing an opening bracket. I suspect you're thinking of ARC or Automated Reference Counting. Here's a link to the documentation (http://clang.llvm.org/docs/AutomaticReferenceCounting.html).

This. Read the ARC documentation.

A few notes: If you activate ARC for an existing project, you have to remove all retain/release calls in the ObjC parts of the Code. Otherwise the compiler will complain.

You will need to understand "strong" and "weak" properties - this is something I stumbled upon.