fuzzygoat
fuzzygoat

Reputation: 26223

Using copy with setter?

I wonder if I can just check something that I have not tried before, does this seem ok, bit of a simple question but I wanted to make sure I was understanding things. All the components of CCLocation comply to NSCopying so I am assuming that masterLocation is a deepCopy, dulicate CLLocation with duplicate iVars.

        CLLocation *tempLocation = [lastGoodLocation copy];
        [self setMasterLocation:tempLocation];
        [tempLocation release];

and could I replace it with

        [self setMasterLocation:[[lastGoodLocation copy] autorelease]];

Master location is defined as:

        @property (nonatomic, retain) CLLocation *masterLocation;

EDIT:

So I could do:

@property (nonatomic, copy) CLLocation *masterLocation;
[self setMasterLocation: lastGoodLocation];

Upvotes: 1

Views: 529

Answers (1)

unexpectedvalue
unexpectedvalue

Reputation: 6139

Yes.

@property (nonatomic, copy)

as well, as BoltClock said.

Upvotes: 1

Related Questions