Should this value be released?

I got a segfault 11 memory access error in the iOS simulator, but it disappears when I comment on the release in the code below.

// get get the question number NSString *text = [attributeDict valueForKey:XML_TAG_QUESTION_ATTRIBUTE_NUMBER]; question.number = [text intValue]; //[text release]; <==== no more segfault 11 when this is commented out. 

My question is, since I get the NS String instance returned by the NSXMLParser implementation, the number of links is not increasing, and I should not release it?

+2
memory-management ios
Feb 25 2018-11-21T00:
source share
2 answers

Here's the rule: always NARC in your memory management.

If you call:
(N) EW
(A) Lloc
(R) etain or
(C) opy ...

You need to free. If not, you received it using the convenience method and autorealized it.

In the case of containers with other objects, the container stores the objects, and you do not need to worry about it until you release the container.

+13
Feb 25 2018-11-21T00:
source share
+2
Feb 25 2018-11-21T00:
source share



All Articles