开发者

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


Yes.

@property (nonatomic, copy)

as well, as BoltClock said.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜