How do I populate the content values of a NSPopUpButton dynamically using a XML file?
I need to use arrays, right?
Please, please provide example code.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t have to, although it would make things easier. You need to extract the data from your XML file; take a look at the NSXMLDocument documentation, and the documentation for its superclass, NSXMLNode; these classes make it fairly easy to retrieve different “nodes” from your XML, and place them into an array. From there, it is easy to retrieve their string values, add this information to your
NSPopupButtoninstance:Where
objectsis anNSArray(orNSMutableArray) containing the titles of the items you want to add to the pop up button, andpopUpButtonis the pointer to yourNSPopUpButtoninstance.This article should also provide you with some more information about working with XML data and retrieving data from it.