tags:

views:

59

answers:

2

Hello there,

learning Cocoa can be pretty tough for web developers. Some things are so simple in HTML, and I have no idea, how to do this in Cocoa.

Let me just show you an image here, to show you what I have on my mind. alt text

So it's kinda like a blog. Each post has variable length, so it can take up some space. Also, you're able to scroll through posts.

I was thinking about using NSTableView or NSCollectionView, but since I don't know much about Cocoa, I'm asking you for advice.

Also please do link any related articles.

Updates

So here are some things that I discovered.

  1. I could make a subclass of NSCell and use it in Table View. I can use it, I can put there a string, something like this:

http://pastie.org/1140412

(please take a look at this code, I'm wondering if I should use awakeFromNib/setDataCell combination)

  1. But string is not enough. I need a NSTextView. The problem is, it doesn't have method like drawInRect: withAttributes:. So I don't know how to draw it into that cell. I guess I'm missing some basics here, so I'm just gonna study some Cocoa views now.

Any ideas are welcome.

+1  A: 

You want to use a NSTableView. And I will recommend to take a look/glance at NSTableView, NSTableViewDelegate and NSTableViewDataSource docs: http://developer.apple.com/mac/library/documentation/cocoa/reference/ApplicationKit/Classes/NSTableView_Class/Reference/Reference.html

http://developer.apple.com/mac/library/documentation/cocoa/reference/NSTableViewDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40008622

http://developer.apple.com/mac/library/documentation/cocoa/reference/ApplicationKit/Protocols/NSTableDataSource_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40004178

You choose the object you want to be your datasource depending on the data you have. The delegate is the object that helps you to so some settings, like rows, groups, cells, etc. There are useful methods of NSTableViewDelegate you want to implement like – tableView:heightOfRow:

and just google NSTableView tutorial or something, there are many good examples ;)

nacho4d
You'll also want to subclass and override NSTableViewCell to achieve the desired appearance.
Rick
There is no NSTableViewCell. You want to subclass one of the NSCell subclasses, or NSCell directly.
Peter Hosey
I think this whole subclassing/custom views will be the hardest part. I guess I don't need data source since I'm using core data - s that right?
Vojto
You must have a datasource object. Sometimes this object is the same as your controller, etc. If you are using CoreData, then the object that is handling CoreData stuff is most probably to be your datasource object (since you didn't show any code).
nacho4d
You don't need a data source if you use Bindings to hook up each of your table columns to an array controller.
Peter Hosey
A: 

You could just use a WebView and write it in HTML.

Look at http://mattgemmell.com/source for an example: the Skinnable App one.

Amorya
I could also write the whole thing in HTML and wrap it in Fluid. I definitely don't want to go this way.
Vojto