开发者

iPhone Apps, Objective C, a Graph, and Functions vs. Objects (or something like that)

Gentleones,

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.

So my questions are:

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 - Should it be an object in some way? Or should it be a straight function? (In either case, where's it belong?)

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜