I have an instance variable CGMutablePathRef _mutablePath which I set as @property (nonatomic) CGMutablePathRef mutablePath; . I override the setter method:
- (void) setMutablePath:(CGMutablePathRef)mutablePath
{
if (_mutablePath)
{
CGPathRelease(_mutablePath);
_mutablePath = NULL;
}
_mutablePath = CGPathRetain(mutablePath);
}
However I am getting a warning on this line: _mutablePath = CGPathRetain(mutablePath); that says:
Assigning to 'CGMutablePathRef' (aka 'struct CGPath *') from 'CGPathRef' (aka 'const struct CGPath *') discards qualifiers
Why would this not work? This seems to work with CT (core text) objects when I do it. I’ve tried a bunch of different casts but can’t get the error to go away, any advice would be appreciated.
CGPathRetain()is declared asThis means it returns a
CGPathRefinstead of aCGMutablePathRef. You should cast the result back toCGMutablePathRefbefore assigning it to your_mutablePathivar.