I’m new to objective c and trying to grasp the delegate methology and usage. Currently i have Alertview class, and i need it to make a another class to call function of its. I’v managed to do the same with with appdelegate class. But can’t do it with my own class.
TableViewController *newControll = (TableViewController*)[UIApplication sharedApplication].delegate;
[newControll openSettings];
That’s how I’m trying to access my method. Compilator see’s this method in newControll, yet calling this gets unrecognizet selector.
Basicaly i need to call a function of which was already created earlier, from another class. I’m sorry if this is a simple solution, but i just can’t grasp delegate and objective-c quite well yet.
Maybe not everyone get’s what I need to do, so i’ll try to explain once more.
I have object TableViewController. From this object inside I’m calling class AlertView to display some alert message. And accordingly to user interaction in alert dialogs (password is ok, password isn’t) I need to call method openSettings in my TableViewController or not call. So how to do this?
If your
TableViewControlleris not your appdelegate class, you should use the object ofTableViewControllerto use the methodopenSettings.It should be something like,
Assuming that you are moving to a new
alertView. In yourAlertView.hfile add,And while creating the new
alertViewobject,Now in your
AlertViewclass, call it as,Usage of appdelegate is not the way to do it.
If you need some tutorials on iOS, check raywenderlich.