Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!!!!

like image 467
Olsi Avatar asked Nov 30 '22 05:11

Olsi


1 Answers

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])
like image 184
Jonathan Grynspan Avatar answered Dec 09 '22 15:12

Jonathan Grynspan