iPhone应用程序,Objective C,图表以及函数与对象(或类似对象) [英] iPhone Apps, Objective C, a Graph, and Functions vs. Objects (or something like that)

查看:45
本文介绍了iPhone应用程序,Objective C,图表以及函数与对象(或类似对象)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

绅士,

我有一个UIView中有一个UIImageView.此特定的UIImageView显示图形的PNG.对于这个特定的视图控制器和另一个视图控制器,重要的是要了解图形的外观",即PNG图形描述的功能.这些其他视图控制器需要能够通过X值返回Y值来调用某种函数".

I've got a UIImageView that I have in a UIView. This particular UIImageView displays a PNG of a graph. It's important for this particular view controller and another view controller to know what the graph "looks like," i.e., the function described by the PNG graph. These other view controllers need to be able to call a "function" of some sort with the X value returning the Y value.

(从局外人的角度来看,请忽略这一事实,我可能可以通过编程方式生成图形.

Please ignore the fact (from an outsider's perspective) that I could probably generate the graph programmatically.

所以我的问题是:

1-我应该在哪里放置此功能?它应该在一个视图控制器中还是在另一个视图控制器中,还是应该在其自己的类或main或...中?

1 - Where should I put this function? Should it go in one view controller or the other, or should it go in its own class or main or...?

2-它是否应该以某种方式成为对象?还是应该是一个直线函数?(无论哪种情况,它属于哪里?)

2 - Should it be an object in some way? Or should it be a straight function? (In either case, where's it belong?)

请原谅问题的实质.这是因为老实说我是n00b!这些OOP东西使我成为一名程序程序员已有30多年的经验了.(而且我选择跳到iPhone应用程序中来学习它.谈论着受洗受洗!)

Pardon the apparent n00b-iness of the question. It's 'cause I'm honestly a n00b! This OOP stuff is giving my head a spin having been a procedural programmer for >30 years. (And I choose to learn it by jumping into an iPhone app. Talk about baptism by fire!)

预先感谢,
条例草案

Thanks in advance,
Bill

推荐答案

图形数据和处理该数据的代码是模型的一部分,而不是视图或控制器的一部分.创建一个单独的类来封装图和相关方法,并在需要操纵它的控制器之间传递一个实例.

The graph data and the code that processes it is part of your model, not your view or your controller. Create a separate class that encapsulates the graph and associated methods and pass an instance between the controllers that need to manipulate it.

这篇关于iPhone应用程序,Objective C,图表以及函数与对象(或类似对象)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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