iphone - Creating an object to act as a delegate - Objective C -


My question is really simple, how can I create an object to act as a representative, my representative Instead of joining the delegates to see?

For example, I have X functionality, which requires representative methods, and they are currently setting up to use themselves as a representative.

What is the best way

For example, NSXMLParser representative methods - they exist, the representative I have been defined, but I do not want to call them as my own idea of ​​form / p>

Controller .. What choice do I have?

If you wish, you can specify another custom class to control the delegation method. Just create a square, call it MyXMLParserDelegate or something similar. Then, tell your NSXMLParser object to what you have to do, that it should be used as a representative of your class.

If you are using the interface builder, then add a new object to the XIB file, set your class to MyXMLParserDelegate and then enter your NSXMLParser delegate of the object.

If you are doing it according to the program, then the basic operation looks like this:

  MyXMLParserDelegate * myDelegate = [[MyXMLParserDelegate alloc] init]; [Delegate some XMLParser set: myDelegate]; Keep in mind that delegates are not kept, so to do this you should add a type of  MyXMLParserDelegate  to do without leaking memory. ViewController class, and then do the following: 

  // in your @ interface block: {... MyXMLParserDelegate * myDelegate; } // in your init method: myDelegate = [[MyXMLParserDelegate alloc] init]; // in your awakeFromNib method (or somewhere appropriate): [Some XMLParser setDelegate: myDelegate]; // in your dealloc method: [myDelegate release];  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -