开发者

ViewController - how to use it properly?

newbie question

开发者_如何学Go1) do you create a ViewController per set of function or 2) just 2 viewcontroller (one for when user is not logged in, and another when user is logged in)

which is the best way to do it? any example how to use viewcontroller properly?

EDIT: If you have the following, should there be two ViewControllers? or just 1 viewController for both message and accountprofile feature?

MESSAGE
ViewMessages
ReadMessage
SendMessage

ACCOUNTPROFILE
ShowAccountProfile
EditAccountProfile


  1. Lecture 6 from CS193P

  2. View Programming Guide for iOS from apple


A view controller should be used to control only 1 single view "main view" which can contain several other views like buttons and so on. I don't know what you are trying to do exactly but my guess is you have 2 views, 1 logged in view and 1 for when the user is not logged in.

You should have 2 view controllers to handle those if thats the case, 1 for the logged in and 1 for the other.

Try to make sure you are not going to make "god classes" as they're called. Like 1 single class that does everything in your app. Such classes are really hard to maintain and will only lead to weird code architecture

Also give each view controller its own XIB

As Terente lonut Alexandru said, you should read the View Programing Guide on developer.apple.com, it explains about how to do MVC ( Model - View - Controller ) properly

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜