Objective-C displaying an array of objects
I was wondering, how, using objective-c + IB, would I output each object in an array into it's own row in a view. Take for example, Tweetie, say I had an array fu开发者_高级运维ll of tweets (NSStrings), I would like to output each tweet (or nsstring) in it's own bubble as is implemented in tweetie.
I know it's slightly confusing but any help would be appreciated!
Thanks in advance! - I'm doing mac dev by the way.
Take a look on NSTableView (on Mac) and UITableView (on iPhone) basic examples.
To get a view like Tweetie for Mac's, an NSTableView of custom NSCells in an NSScrollView would probably be the simplest way. Basically, the first NSTableColumn would be bound to the users' avatars and the second would be a custom "bubble" NSCell that displays the username, time and text of the tweet. Each row would need to have its height determined dynamically, but fortunately, NSTableView can do that these days.
Note that this is far from the only way to do it, and it's probably not even the best. It's just the simplest that immediately occurs to me. Hopefully the description helps give you a push in the right direction.
The easiest way to do this is to use a UITableview and just link up the array as the datasource.
See here for how to implement it
精彩评论