简体   繁体   English

在NSTableView行中显示多个对象

[英]Show more than one Object in a NSTableView row

I'm new here at stackoverflow :) But I think, this is the right place to ask my question. 我是stackoverflow的新手:)但是,我认为,这是问我问题的正确位置。 I'm a new developer with Cocoa and Objective-c & I'm trying to write my first App for Mac: a ToDo App. 我是Cocoa和Objective-c的新开发人员,我正在尝试为Mac编写我的第一个应用程序:ToDo应用程序。

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. 目前,我可以保存待办事项并删除它们,但是现在,我想添加一些功能,例如CreationDate,一些标签(在mutablearray中)以及ToDo是否完成。 Im not working with an ArrayController, I'm saving the encoded NSMutableArray into a File (Library/Application Support/AppName) and reading it from there. 我无法使用ArrayController,我将已编码的NSMutableArray保存到文件(库/应用程序支持/ AppName)中,然后从中读取文件。

This all must be in one Row, because it is looking Like this: 这一切都必须在同一行中,因为它看起来像这样:

Current appearance http://img683.imageshack.us/img683/7595/bild2ss.png 当前外观http://img683.imageshack.us/img683/7595/bild2ss.png

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) 标题应该是待办事项的内容,蓝色框应该是状态(蓝色=撤消,灰色=完成),字幕应该是日期和标签(03.01.2009-tag1,tag2 ,标签3)

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. 我现在如何将对象添加到可变数组中,但是,如果我想将所有这4条信息保存到该数组中,我将不知道该如何做。

I've got an Model, which is initializing with this 4 infomations, but how to save this? 我有一个Model,正在使用这4条信息进行初始化,但是如何保存呢? Must I save this for informations in one array and this array in my mutablearray? 我是否必须将此信息保存在一个数组中并将此数组保存在我的可变数组中?

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. 这是您的模型层( MVC中的M)进入的位置:每行的对象是一个Model对象 ,是您构造的类的实例,而icon,title和subtitle是该对象的属性。

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. 单元是视图层(MVC中的V)的一部分。

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. MVC中的C位于模型和视图之间:它是拥有模型的对象,并且是表视图的数据源(无论是否通过绑定)。 The table view gets the model objects from this object to feed them to the cell. 表格视图从该对象获取模型对象,以将其馈送到单元格。 This middle object is a Controller. 这个中间对象是一个控制器。

Now i have it! 现在我拥有了!

I've only one Cell for the Content with an ArrayController. 我只有一个单元格用于ArrayController。

I'm setting the other Informations with -(id)init for each row. 我为每行设置其他信息-(id)init。

There are 3 Objects: content, status and date, and for each status i display another image (done, undone, ...). 有3个对象:内容,状态和日期,对于每个状态,我会显示另一个图像(完成,撤消,...)。

Thank you very much for your Help! 非常感谢您的帮助! I'm trying to finish the Beta for everyone :) 我正在尝试为每个人完成Beta版:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM