Xcode显示有关unsafe_unretained的警告,但不确定如何解决此问题

时间:2015-06-23 19:27:32

标签: objective-c automatic-ref-counting

    MDRadialProgressTheme *newTheme = [[MDRadialProgressTheme alloc] init];
    newTheme.completedColor = [UIColor whiteColor];
    newTheme.incompletedColor =[UIColor darkGrayColor]; //[UIColor colorWithRed:177/255.0 green:179/255.0 blue:181/255.0 alpha:1.0];
    newTheme.centerColor = [UIColor clearColor];
    //newTheme.centerColor = [UIColor colorWithRed:219/255.0f green:220/255.0f blue:221.0 alpha:1.0f];
    newTheme.sliceDividerHidden = YES;
    newTheme.labelColor = [UIColor blackColor];
    newTheme.labelShadowColor = [UIColor whiteColor];

    CGRect frame = CGRectMake(0,0, 45, 45);

    radialView = [[MDRadialProgressView alloc] initWithFrame:frame andTheme:newTheme]; // warning here
    // Assigning retained object to unsafe_unretained variable; object will be released after assignment

    radialView.center=CGPointMake(self.bounds.size.width / 2.0f, self.bounds.size.width / 2.0f);
    radialView.progressTotal = 4;
    radialView.clockwise =YES;
    radialView.label.hidden =YES;
    radialView.progressCounter = 1;
    [self addSubview:radialView];

我在行上发出警告 radialView = [[MDRadialProgressView 将保留对象分配给unsafe_unretained变量;对象将在作业后发布

这是什么意思,我该如何解决?

 @property (nonatomic,assign) MDRadialProgressView *radialView;

在标题中声明了radialView(见上文)

1 个答案:

答案 0 :(得分:2)

将您的财产更改为

@property (nonatomic, strong) MDRadialProgressView *radialView;