[英]Assigning to 'int' from incompatible type 'int (^__strong)(void)'
I am trying to call a block that returns me a random finalItemID
(int) according to state of the app. 我正在尝试调用一个块,该块根据应用程序的状态返回一个随机的
finalItemID
(int)。 But the app fails to build because of the error: 但由于出现错误,该应用无法构建:
Assigning to 'int' from incompatible type 'int (^__strong)(void)'
从不兼容类型'int(^ __ strong)(void)'分配给'int'
My code: 我的代码:
//block declaration
int(^getMeAnItem)(void)=^int(void)
{
int finalItemID=0;
//some randomization code
return finalItemID;
};
int itemIDToBeChecked=0;
itemIDToBeChecked= getMeAnItem; //red error appears on this line
I am not seeing anything wrong going here. 我没有发现任何错误。 I hope you guys can help.
希望你们能帮上忙。 Thanks.
谢谢。
要调用一个块,您需要实际调用它:
itemIDToBeChecked = getMeAnItem();
You initialise a variable named getMeAnItem. 您初始化一个名为getMeAnItem的变量。 An initialisation always ends in a semicolon.
初始化总是以分号结尾。 Yours doesn't.
你的不是。
括号呢?
itemIDToBeChecked = getMeAnItem();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.