开发者

Using copy with setter?

开发者 https://www.devze.com 2023-02-19 07:46 出处:网络
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

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];


Yes.

@property (nonatomic, copy)

as well, as BoltClock said.

0

精彩评论

暂无评论...
验证码 换一张
取 消