Monday, 2 September 2013

calling a method inside someClass from AppDelegate Objective-C IOS

calling a method inside someClass from AppDelegate Objective-C IOS

I'm trying to call a method that's inside someClass from the AppDelegate
class. I usually create an instance and then using that instance, call the
method. Like so:
FFAppDelegate *delegate = (FFAppDelegate *) [[UIApplication
sharedApplication] delegate];
[delegate someMethod];
I use that ^^ quite a bit in my code and it works perfectly. What I want
to do, is switch it around. Instead of calling a method INSIDE the
AppDelegate, I want to call a method inside another class FROM the
AppDelegate.
SomeClass *test = (SomeClass *) [[UIApplication sharedApplication] delegate];
[test someMethod];
In this case, I keep getting "Terminating app due to uncaught exception
'NSInvalidArgumentException'" error due to "unrecognized selector sent to
instance".
Any light shed on the matter would be greatly appreciated! :)

No comments:

Post a Comment