I need a simple ListBox where I can just insert many items whenever I like. I've been told to use a NSTableView, but the tutorials I have found are all overkill for this scenario and since I am new to OS X development, it's also very difficult to follow along when all I want is something simple , first.
How do I insert a bunch of items when I click a button ? All of the tutorials seem to rely on some underlying datasource - but for some reason there don't exist any tutorials for those occasions where we're not collecting anything from a database, or an XML file.
In C# for example, I can do:
private void button1_Click(object sender, EventArgs e)
{
for(int 1 = 0; i < 10; i++)
{
listBox1.Items.Add("Item " + i.ToString());
}
}
So that's basically all I am trying to do right now.
You can do this in a simple way using the Cocoa bindings which can be achieved using a array controller and a array.
The apple developer docs has this tutorial explaining the same, https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/TableView/PopulatingViewTablesWithBindings/PopulatingView-TablesWithBindings.html
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.