error: invalid lvalue in assignment
error: invalid lvalue in assignment
- Subject: error: invalid lvalue in assignment
- From: Don Arnel <email@hidden>
- Date: Mon, 25 Aug 2008 19:25:14 -0400
Hello everyone!
I'm having a problem using a property for one of my custom class
objects.
I have a class like this:
INTERFACE (MyObject.h):
-----------------------------------
typedef struct {
float x;
float y;
} Vector2D;
@interface myObject : NSObject {
Vector2D _position;
}
@property Vector2D position;
@end
IMPLEMENTATION (MyObject.m):
---------------------------------------------
@implementation myObject
@synthesize position=_position;
- (id)init
{
if ((self=[super init]) != nil) {
_position.x = 0.0;
_position.y = 0.0;
}
return self;
}
@end
I tried to modify the "position" property in another file after
creating an object but I get this error:
obj.position.x += 1.0;
(x error: invalid lvalue in assignment)
I can assign the value without a problem:
float x = obj.position.x;
x += 1.0;
But then this is also a no-no:
obj.position.x = x;
Anyone have any ideas as to why the first assignment gives an error?
Thanks for any and all help.
- Don
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden