I have instance of interface that displays a map.
I am calling to that map from other interface and displaying it, now i want to start a function (func5) that in the map interface.
I’m creating:
myMap *map = (myMap*) [[UIApplication sharedApplication] delegate];
[map func5:2];
this func5 i declared in myMap interface.
-(void) func5:(int) num;
but i’m getting an error when trying to run this line: [map func5:2];
'NSInvalidArgumentException', reason: '-[AppDelegate func5:]: unrecognized selector sent to instance 0x952b140'
what is the problem?
First, its a terrible thing to put methods like this on the app delegate, generally you want those methods in their own instances.
Second, AppDelegate must have
declared in the header (that is AppDelegate.h)
From the code here I am assuming that by “instance” you mean your AppDelegate, and not something else like *MyMapClass myMap; thing.
If it is the second one then you have to make myMap a declared property in the header of the app delegate and then call it this way:
and add the header in where you want to call the function.
STILL this is a terrible practice.