views:

204

answers:

2

Hi, I'm new here at stackoverflow :) But I think, this is the right place to ask my question. I'm a new developer with Cocoa and Objective-c & I'm trying to write my first App for Mac: a ToDo App.

At this moment, i can save ToDo's and delete them, but now, I want to add some features like CreationDate, some Tags (in mutablearray), and if the ToDo is finished or not. Im not working with an ArrayController, I'm saving the encoded NSMutableArray into a File (Library/Application Support/AppName) and reading it from there.

This all must be in one Row, because it is looking Like this:

Current appearance

Where Title is, should be the Content of the ToDo, where the Blue Box is, should be the Status (Blue = undone, Grey = Done) and where Subtitle is should be the Date and the Tags (03.01.2009 - tag1, tag2, tag3)

I now how to addObjects into an mutablearray but, if i wanna save all this 4 informations into this array, i dont know how to make this.

I've got an Model, which is initializing with this 4 infomations, but how to save this? Must I save this for informations in one array and this array in my mutablearray?

+5  A: 

The solution is actually the opposite: Have one object per row.

This is where your model layer (the M in MVC) comes in: The object for each row is a model object, an instance of a class you construct, and the icon, title, and subtitle are properties of that object.

Then, make a custom cell for your table column to display the model object in that way. The cell is part of the View layer—the V in MVC.

The C in MVC sits in between the Model and View: It's the object that owns the model and is the data source (whether by Bindings or not) of the table view. The table view gets the model objects from this object to feed them to the cell. This middle object is a Controller.

Peter Hosey
You don’t necessarily need to create custom cells for this. You could get away with an attributed string for the title and subtitle and use an NSImageCell for the status.
Chris Suter
True, but stuffing three separate property values into a single attributed string is a dirty way to do it. Displaying them in that specific way is a View job, and forging an NSAttributedString to do it would have to happen in either the Controller or the Model—the two sections of the code that should not care about display.
Peter Hosey
thank you for your help, now I'm working with an array Controller and i have 4 columns :) I'm trying to get this working...
ahmet2106
I'm not getting further.I have the 3 Columns (1. Content 2. Date 3. Status) and i can edit this 3 Columns, but now, I want to display them in just one row, (see pic above). How to make this?Now I'm using the ArrayController because this is easier and better to understand and I'm saving it in the Document like before.What should I do now? Is there any Sample Code? Than it would be easier to understand...BTW Thank you Peter Hosey and Chris Suter :)
ahmet2106
I didn't express this clearly; sorry: You need to make it *one* column. Then, as I said above, use model objects as the values in the column, and give the column a custom cell to display the model object in the way you showed in your question. [edited to clarify the clarification]
Peter Hosey
A: 

Now i have it!

I've only one Cell for the Content with an ArrayController.

I'm setting the other Informations with -(id)init for each row.

There are 3 Objects: content, status and date, and for each status i display another image (done, undone, ...).

Thank you very much for your Help! I'm trying to finish the Beta for everyone :)

ahmet2106