Is a literal NSString autoreleased or does it need to be released?

When creating a string using the following notation:

NSString *foo = @"Bar";

Does one need to release foo? Or is foo autoreleased in this case?

Answers


Compiler allocated strings (of the format @"STRING") are constant, and so -retain, -release, and -autorelease messages to them are ignored. You don't have to release or autorelease foo in this case (but it won't hurt).


Need Your Help

Least CPU intensive way to Frequently & Repeately Draw Many Views

iphone ios performance ipad quartz-graphics

This Is a problem that I've been leaving and coming back to for a while now. I've never really nailed the problem.

Listing available devices in python-opencv

python linux opencv hardware

I have two webcams attached to my laptop (one built in), both of which work. (If I use Cheese, a webcam thingy that comes with Ubuntu, it uses the external one). If I use

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.