简体   繁体   中英

Calling Application delegate file method from main view controller

The situation I am running in is that, I have a login Button which is having NSURLConnection method in the main view controller and when button is pressed it will be active and and XML file will be downloaded. Now to parse that XML file the method which is parsing is in application delegate file.

Now I want to know that how can I call that function from within the login button. And also that from that parsed file I have to check a value that if it is more than 1 or less than one. So that the action would be taken that to which view it will be transitioned.

any help will be appreciated.

If the method to do your parsing lives in the application delegate, then getting a hook to it can be as easy as:

MyFineApplicationDelegate * appDelegate = 
    (MyFineApplicationDelegate *)[[UIApplication sharedApplication] delegate];

And then you can call [appDelegate parseMyXMLData: myXMLData];

Makes sense?

Try This..
In .h
#import "Appdelegatefile.h"

Appdelegatefile * appDelegate;


IN .m 
{
 appDelegate =(Appdelegatefile *)[[UIApplication sharedApplication] delegate];
[appDelegate //here you can call method of delegate file ];

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM