开发者

Where is the best pIace to handle repeated casting of variables? (UITextField -> math calculation -> UILabel)

I am creating an app that takes a user's body measurements, and then calculates body metrics from the user inputted measurements.

I have view controllers classes that collect user data via UITextfields (which are stored as NSStrings), which then is passed to a class that calculates the data (needs NSNumber). This model class then passes back the result to the view controller to be displayed in the UILabels (which needs NSStrings). No issues, no problems with the code.

My question is: Is there a common design pattern for where to handle all this casting? Is it as soon as the data is collected, inside the model class that does the calculati开发者_高级运维on, create a class that will handle the casting?

I know all of these options are available to me, but which makes for more readable and easily grokked code?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜