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
- Delivered-to: email@hidden
- Delivered-to: email@hidden
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :content-type:mime-version:subject:date:x-mailer; bh=yupGTIAYw7aDm5dHf1CnW67rfpk9H9WSCKJwZat43BM=; b=T2iRjlGK4vjx9ji9GxFMYBNkHbKgUjiRzJTXITW58bVmlFAj9j8pMQvR4AFNOxS9QY yyT8qCvC1I1HvYcRdm9UegoH0MZANCLTbgHKThsWN8l/agN45GcyEYLI93NXI9GRcAN6 gD1GSCBrCUn+dMRWWLaVUKDD5JpD/SYSZN6ig=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:mime-version:subject:date:x-mailer; b=GWyZjZ/+otwohtdlX9Un+HOJ9FzbbAYV5L7ZrWP1TLXMNkWwFjPQrtp4pYNlltvqgN 9Et/Vt6AC+f4lGU1Lzup9hsbqyPCOZcF2M1HU4FHQY4WBX7wD2i1bOHO5OYFHma/amNB 2DwJcuUr0+tXm5gSC88tGuEPBPZV5Hzmyv/s8=
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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden
This email sent to email@hidden
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.