Mac [NSString release] in XCode 4.2??

Fritzables

macrumors regular
Original poster
May 6, 2011
147
1
Brisbane AUSTRALIA
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:

Code:
NSString *aString = [NSString alloc] init];
do I still need to:

Code:
[aString release];
or will it be looked after by XCode4 ??

Pete
 

gnasher729

macrumors P6
Nov 25, 2005
16,530
3,126
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:

Code:
NSString *aString = [NSString alloc] init];
do I still need to:

Code:
[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

macrumors 68030
Oct 19, 2011
2,984
7
Switzerland
You're missing an opening bracket. I suspect you're thinking of ARC or Automated Reference Counting. Here's a link to the documentation.
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.