Search code examples
iosobjective-ccgrect

Expression is not assignable error with CGRect


I'm trying to create a CGRect property.

@property (nonatomic) CGRect myRect;

Then later on, I set the frame:

self.myRect = self.frame;
self.myRect.size.height = 10; // Error

I get an error saying "Expression is not assignable". Why do I get that? Can't I change the size of a CGRect?


Solution

  • Do it this way.

    _myRect = self.frame;
    _myRect.size.height = 10;