【发布时间】:2014-01-03 08:05:37
【问题描述】:
我有一个应用程序可以帮助对设备进行故障排除。要进行此故障排除,我会提出建议,然后要求用户输入他们必须回答才能继续的问题。根据答案,我会加载一个包含一组新建议和问题的新视图。我不确定我是否了解 MVC 设置的模型部分。我有一个模型,其中包含建议、suggestions_images、问题、答案……然后我还将问题链接到新的模型对象。我只想知道这是否被认为是最佳实践?还是我误解了MVC的设计方案?
编辑:这是我的模型概述:
#import <Foundation/Foundation.h>
@interface troubleshootingInfo : NSObject {
NSString *stepTitle;
NSString *stepCount;
NSString *description;
NSString *imageTitle;
NSString *descriptionImageLink;
NSString *questionTitle;
NSMutableArray *actionsToPerform;
NSMutableArray *actionsStatus;
NSMutableArray *actionsImage;
NSMutableArray *actionImageTitle;
NSMutableArray *logActions;
troubleshootingInfo *nextNoObject;
troubleshootingInfo *nextYesObject;
// This is to be used with selections
NSMutableArray *userInputForAction;
}
//perform function on the set values
- (int) setActionRowHieght:(int)actionID; // get row hieght for table cell
- (int) setDescriptionRowHeight; // get row hieght for table cell
- (int) setQuestionTitleHeight; // get row hieght for table header
- (int) actionCount; // the number of actions in the actionsToPerform array
- (BOOL) isAction; // is action set
- (BOOL) isDescription; // is description set
- (BOOL) isQuestion; // is question set
- (BOOL) isActionPerformed:(int)action; // check if action is performed
- (BOOL) isActionImage:(int)action; // check if action has an image
- (NSString *) updateActionPerformed:(int)action;
任何帮助都会很棒。 谢谢
编辑:根据建议修复代码(我认为)。
我现在的头文件。
@interface TroubleshootingInfo : NSObject
// values of the class
@property NSString *stepTitle;
@property NSString *stepCount;
@property NSString *description;
@property NSString *imageTitle;
@property NSString *descriptionImageLink;
@property NSString *questionTitle;
@property NSMutableArray *actionsToPerform;
@property NSMutableArray *actionsStatus;
@property NSMutableArray *actionsImage;
@property NSMutableArray *actionImageTitle;
@property NSMutableArray *logActions;
@property TroubleshootingInfo *nextNoObject;
@property TroubleshootingInfo *nextYesObject;
// This is to be used with selections
@property NSMutableArray *userInputForAction;
//perform function on the set values
- (int) actionCount; // the number of actions in the actionsToPerform array
- (BOOL) hasAction; // is action set
- (BOOL) hasDescription; // is description set
- (BOOL) hasQuestion; // is question set
- (BOOL) isActionPerformed:(int)action; // check if action is performed
- (BOOL) ihasActionImage:(int)action; // check if action has an image
- (NSString *) updateActionPerformed:(int)action;
好的,很抱歉造成混乱。我的问题与分层数据模型和表视图有关。在阅读了 Apple 的文档后,我觉得我对如何处理复杂的表有了更好的了解。我相信我在这里介绍的课程实际上需要与更复杂的数据模型分开。我会重新考虑我的设计。谢谢。
【问题讨论】:
-
你考虑过什么?您的模型需要保存哪些类型的信息以及如何构建它?
-
@Kevin 我已经展示了我想要使用的自定义对象。我不确定这种结构是否是个好主意。
-
多么令人兴奋,这就像工作中的同行评审!我注意到班级没有 cmets。也许添加一些 cmets 让其他编码人员确切知道它的作用可能会有所帮助。
-
我试图缩小到我实际要求的范围。问题是基于表格的应用程序的层次结构设计。