jclc
jclc

Reputation: 3

global integer assignment - lvalue required as left operand of assignment

I am new to objective c and I am trying to change the value of a global integer in objective c but the compiler is complaining with the following message: "lvalue require as left operand of assignment".

Here is the line of code:

[[UIApplication sharedApplication].delegate someNSIntegerValue] = myNSIntegerValue;

I am sure the answer to this is simple, so simple in fact that I cannot find an answer for what I am doing wrong.

Upvotes: 0

Views: 288

Answers (2)

fresskoma
fresskoma

Reputation: 25781

As Thomson Corner has already said, someNSIntegerValue is probably a getter. But even if it was not, what you are doing there can not possibly work, because it translates to this:

[someInstance someMethod] = someValue;

or in C

someFunction() = someValue;

This hopefully makes clear that its wrong. What you could try:

[[UIApplication sharedApplication].delegate setSomeNSIntegerValue: myNSIntegerValue];

Or the property-ish way (in case you @synthesize'd one):

[UIApplication sharedApplication].delegate.someNSIntegerValue = myNSIntegerValue;

Note that the last example should actually do the same as the one before that.

Upvotes: 4

Thomson Comer
Thomson Comer

Reputation: 3919

someNSIntegerValue is the getter method for a property if that's what you put in your AppDelegate. Try setSomeNSIntegerValue instead.

Upvotes: 0

Related Questions