views:

70

answers:

1

Hello.

I`m really new in Objective-C and Mac OSX programming.

Can someone give me simple example for the next task: I have array of strings (for example ('one','two','three','four')) in my app GUI each string should be represented by row, each row should has Label(with text of string) and CheckBox. Number of strings in array may be different. How i can dynamically create this GUI objects?

It is like in Transmission app, when you open torrent file and window opens with list of files and checkboxes

+1  A: 

D you want to create a table? So what you are looking for is a UITableView object whose rows will be dynamically created after you set the 'data source'(in this case the data source can be your viewController that encapsulates that string array) from which it will get the data dynamically.

You'd better have a look at some documentation about UITableView and their programming

If this is not what you are looking for, you can accomplish your goal by creating many UIView dynamically, adding content to them (UILabels, etc) and position them one after the other on the main UIView as subview calculating their frame position and dimension

rano
Thank you. But your examples about iOS programming but i am asking about Mac OSX programming
Alex Molskiy
His comments still apply. Just substitute NSView for UIView or NSLabel for UILabel. With that said, you can dynamically create GUI objects the same way as any other object - alloc/init. However, the most common thing is to create multiple Nib files and load them as needed and retrieve objects from there.
Wade Williams
Oh, ok :) May be you can point me to some examples?
Alex Molskiy
rano