tags:

views:

37

answers:

1

Let's say my object has a CGRect property named rect.

I want to maintain a single CGRect rather than individual CGSize and CGPoint (for comparison against other CGRects with CGRectContainsRect()) but I want accessors for the individual members so I don't have to recreate a whole new CGRect every time I want to change one or the other.

I thought I'd try:

@synthesize size = rect.size;
@synthesize position = rect.origin;

But the compiler didn't like that. Is there a way to do this without writing custom getter/setters?

+1  A: 

Nope. The @synthesize directive can only take the names of instance variables, not arbitrary expressions.

Chuck