Reputation: 5679
I have a class AudioInfo
which contains some NSString
objects.
In main()
I create (allocate) some AudioInfo
object.
Later in main()
I want to have the second AudioInfo
object with the same NSString
objects.
I init
the second one with NSStrings
from the first one.
Question:
Should I retain the first AudioInfo
object to have them both with retain count = 1 after creating (allocating) the second one?
Upvotes: 0
Views: 61
Reputation: 104698
In this case, AudioInfo
should simply copy
the string properties to its ivars (you should be declaring your NSString
properties copy
by default) and each instance would manage its own references. You then release the AudioInfo
instances when you are finished using them. That's all there is to it.
Upvotes: 1