Xcode is showing a warning about unsafe_unretained and not sure on how to fix this

131 Views Asked by At
    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];

I get a warning on the line radialView = [[MDRadialProgressView saying Assigning retained object to unsafe_unretained variable; object will be released after assignment

What does it mean and how do I fix it?


 @property (nonatomic,assign) MDRadialProgressView *radialView;

radialView is declared in the header (see above)

1

There are 1 best solutions below

2
On BEST ANSWER

Change your property to

@property (nonatomic, strong) MDRadialProgressView *radialView;