简体   繁体   中英

Define the app delegate as a constant?

I'm trying to write an iPhone application, and I have a problem.
I have declared a constant as the app delegate inside a class

#define ikub (iKubMobileAppDelegate *)[[UIApplication sharedApplication] delegate]

And when I need to get the size of an array, which is an instance variable for the application

[ikub.subscriptions count]

I get an error Accessing unknown 'subscriptions' getter method .
I'm not really sure why this is happening.

Please help!!!!

您需要将宏值包装在括号中(否则,宏中的强制转换应用于属性,此时该属性是未知的。)所以:

#define ikub ((iKubMobileAppDelegate *)[[UIApplication sharedApplication] delegate])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM