将应用代理定义为常量? [英] Define the app delegate as a constant?
本文介绍了将应用代理定义为常量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写一个iPhone应用程序,而且我有一个问题。
我已经声明一个常量作为应用程序委托在一个类
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]
我收到错误访问未知的订阅getter方法。
我不太确定为什么会发生这种情况。
I get an error Accessing unknown 'subscriptions' getter method.
I'm not really sure why this is happening.
请帮助!!!!
推荐答案
您的宏值在括号中(否则,宏中的转换适用于该属性,此时该属性未知。)所以:
You need to wrap your macro value in parentheses (otherwise, the cast within the macro applies to the property, which at that point is unknown.) So:
#define ikub ((iKubMobileAppDelegate *)[[UIApplication sharedApplication] delegate])
这篇关于将应用代理定义为常量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文