Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 全局整数赋值-赋值的左操作数需要左值_Iphone_Objective C_Cocoa - Fatal编程技术网

Iphone 全局整数赋值-赋值的左操作数需要左值

Iphone 全局整数赋值-赋值的左操作数需要左值,iphone,objective-c,cocoa,Iphone,Objective C,Cocoa,我是目标c的新手,我正试图更改目标c中全局整数的值,但编译器抱怨说有以下消息:“左值要求作为赋值的左操作数” 以下是代码行: [[UIApplication sharedApplication].delegate someNSIntegerValue] = myNSIntegerValue; 我确信这个问题的答案很简单,事实上非常简单,我无法找到我做错了什么的答案。SomenIntegerValue是属性的getter方法,如果你在AppDelegate中放了这个方法的话。请尝试改为使用set

我是目标c的新手,我正试图更改目标c中全局整数的值,但编译器抱怨说有以下消息:“左值要求作为赋值的左操作数”

以下是代码行:

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

我确信这个问题的答案很简单,事实上非常简单,我无法找到我做错了什么的答案。

SomenIntegerValue
是属性的getter方法,如果你在AppDelegate中放了这个方法的话。请尝试改为使用
setSomeNSIntegerValue

someNSIntegerValue
是属性的getter方法,如果这是您在AppDelegate中放置的内容。试着用
setSomeNSIntegerValue
来代替。

正如汤姆森·科恩(Thomson Corner)已经说过的,
someNSIntegerValue
可能是一种获取方法。但即使不是,你在那里所做的也不可能起作用,因为它转化为:

[someInstance someMethod] = someValue;
或者用C

someFunction() = someValue;
这很有希望表明这是错误的。您可以尝试:

[[UIApplication sharedApplication].delegate setSomeNSIntegerValue: myNSIntegerValue];
或者以类似于属性的方式(如果您@synthesis'd one):


请注意最后一个示例实际上应该与前面的示例相同。

正如Thomson Corner所说,
someNSIntegerValue
可能是一个getter。但即使不是,你在那里所做的也不可能起作用,因为它转化为:

[someInstance someMethod] = someValue;
或者用C

someFunction() = someValue;
这很有希望表明这是错误的。您可以尝试:

[[UIApplication sharedApplication].delegate setSomeNSIntegerValue: myNSIntegerValue];
或者以类似于属性的方式(如果您@synthesis'd one):


请注意最后一个示例实际上应该与前面的示例相同。

感谢您的快速回复。我使用@synthesis创建了属性,我还可以调用setSomeNSIntegerValue吗?是的,使用
@property
@synthesis
创建属性就是使用setSomeNSIntegerValue的方式,只要你不将属性属性设置为
只读
。谢谢你的快速回复。我使用@synthesis创建了属性,我还可以调用setSomeNSIntegerValue吗?是的,使用
@property
@synthesis
创建属性就是使用setSomeNSIntegerValue的方式,只要不将属性属性设置为
readonly
。前导“**”是怎么回事?Anders K:我认为提问者出于某种原因想将其加粗。我会把它删掉。开头的“**”怎么了?安德斯K:我想提问者出于某种原因想把它加粗。我会把它编辑掉。属性是否为
@synthesis
d并不重要;该属性只需在标头中声明。只要显式声明了正确的setter,您甚至可以在没有
@属性的情况下执行此操作;该属性只需在标头中声明。只要显式声明了正确的setter,您甚至可以在没有
@属性的情况下执行此操作。