iOS分析 - 假设“自我”是非愚蠢的

时间:2015-05-13 13:14:32

标签: ios objective-c

我正在分析我的应用程序,并且犯了以下错误。有人可以帮助我吗?

- (id)initWithLayer:(id)layer
{
    self = [super initWithLayer:layer];

    if (self)
    {
        [self setDefaults];

        MCNewCustomLayer *other = (MCNewCustomLayer*)layer;
        self.value              = other.value;
        self.textLabel          = other.textLabel;
        self.selectionStatus    = other.selectionStatus;
        self.animationDuration  = other.animationDuration;
        self.mainPath           = CGPathCreateMutableCopy(other.mainPath);
        self.fillColor          = CGColorCreateCopy(other.fillColor);
        self.strokeColor        = CGColorCreateCopy(other.strokeColor);
        self.mainPathImage      = other.mainPathImage;
        self.identifier         = other.identifier;
        self.parentLayeredView  = other.parentLayeredView;
        self.isAllowedToAnimate = other.isAllowedToAnimate;
        self.imageBoundsStyle   = other.imageBoundsStyle;

        self.isPresentationLayer  = YES;

    }

    return self;


}

警告信息如下:

假设'self'是非零的

调用函数'CGPathCreateMutableCopy'返回一个带有+1保留计数的Core Foundation对象

对象泄漏:此执行路径中未引用已分配的对象,并且保留计数为+1

1 个答案:

答案 0 :(得分:0)

您希望调用CGPathRelease(other.mainPath);来释放保留计数,以免造成内存泄漏。