If I make an NSString using the code below, do I need to need to release someString?
NSString *someString = @"somestring";
No, it's a compile time constant string object, so it doesn't need releasing. It's the moral equiv of char *c = "hello world" -- where the string hello world is in global data, and you're assigning the address of this data to the pointer c.
If you created an object via a method call that contains alloc
, retain
, or copy
, or starts with new
(N-A-R-C = "narc"), then you are responsible for releasing
the object. If this is not the case, then you can ignore the object.
So in the case of strings:
NSString * myString = @"This is a string";
I don't see a call there to a NARC method, so you are not responsible for releasing it. It's really that simple.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With