• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
error: invalid lvalue in assignment
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: error: invalid lvalue in assignment
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Cocoa newbie, activeDocumentChanged, crashes
  • Next by Date: Re: Built Menu not firing the action
  • Previous by thread: Cocoa newbie, activeDocumentChanged, crashes
  • Next by thread: Re: error: invalid lvalue in assignment
  • Index(es):
    • Date
    • Thread