开发者

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 开发者_如何学Pythonwith 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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜