如何在一个MainClass中访问多个类数据? [英] How to Access Multiple Classes data in One MainClass?

查看:124
本文介绍了如何在一个MainClass中访问多个类数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事一个大型项目。所以这就是我的应用程序包含大量代码的原因。这个项目有趣的是,它仅包含一个主视图,并且该主视图包含25个子视图,每个子视图都包含UITableview.so。对我来说,问题是,如果我在主视图中声明所有这些子视图和uitableview以及每个子视图所需的不同功能,它造成混乱。现在,为了方便起见,我想为每个子视图创建单独的类,但是我不熟悉如何在我的mainviewviewcontroller中访问所有这些类。如果仍然有人无法理解我的问题,请访问此链接。 http://chris-software.com/ index.php / 2009/05/02 / passing-data-between-classes /

I am working on one of big project.so that's why my application contains a lot of coding. Interesting thing about this project is that it contains only one mainview and this mainview contains 25 subviews, each subview contains UITableview.so problem for me is that if I declare all these subview and uitableview in mainview along with different function which I need for every subview it create confusion. Now to make it easy I want to create separate class for each subview, but I am not familiar with how to access all these classes in my mainviewviewcontroller. Still if some one not able to understand my problem then please visit this link. http://chris-software.com/index.php/2009/05/02/passing-data-between-classes/

推荐答案

您的注释表明您已经编码了问题中提到的内容,现在,您尝试使代码可扩展并按照zoul的建议将其分开。

It seems from your comment that you already have coded something like you have mentioned in your problem, and now, you trying to make your code scalable and making it separate as zoul has suggested.

正如祖尔已经提到的那样,您的问题没有确切的解决方案,因为您的问题也不是确切的,或者说的很具体。

As zoul has mentioned, There isn't any exact solution to your problem, as your problem is also not exact, or say specific.

不幸的是,这不可能完全解决正如您在评论中提到的,您正在尝试实现的目标。但是,让我尝试给您一些提示,在重构代码时可能会发现您有用。

Unfortunately, It is not fully possible what you are trying to achieve, as you have mentioned in your comment. But, Let me try to give you some hint that you may find useful when refactoring your code.


  1. 确定需要在哪些数据之间共享不同的类。

  2. 为应用程序确定视图控制器。我的意思是说,视应用程序可能需要的View Controller数量。

  3. 如果共享数据的大小相当大,那么我建议您使用SQLite或CoreData来完成该任务。 ,只要满足您的需求即可。

欢迎进行具体查询。
祝您好运:)

Specific query is welcome. Best of luck :)

附加说明:尝试遵循Apple提供的设计模式,最重要的是在SDLC的初始阶段。

Additional Note: Try to follow the design pattern provided by Apple, most importantly in the initial phase of SDLC.

这篇关于如何在一个MainClass中访问多个类数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆