iphone - connect GUI to LOGiC -


i trying build first iphone app. first finish app logic whitch contain datalogic class have arrays. , 2 classes

then build appgui contain 2 views. searchviewclass , resultviewclass problem how connect logic gui. instance of datalogic on appdelegate class , need 2 gui classes able accsess instance dont know accsess instances in appdelegate class gui classes?

i didnt see app initialize gui classes?? gui classes instance??

you use mvc (model-view-controller) design pattern. should called model-controller-view pattern because controller mediates between model , view.

in case datalogic class model. views controlled paired view controller object instance or subclass of uiviewcontroller. depending on app, there many different ways relate view controllers each other, views , model.

the easiest understand navigation based app in xcode template projects. has no data model object have navigation controller , rootviewcontroller class paired view defined in rootviewcontroller.xib. rootviewcontroller instance of rootviewcontroller subclass of uiviewcontroller (usually, rootviewcontroller>uitableviewcontroller>uiviewcontroller.)

in case, add property rootviewcontroller hold reference datalogic class. in app delegate's application:didfinishlaunching: method initialize datalogic instance , set rootviewcontroller's property datalogic instance.

now rootviewcontroller instance connects datalogic instance. when navigation controller pushes rootviewcontroller instance on navigation stack, rootviewcontroller instance's view (assigned in nib file) loads. rootviewcontroller instance takes data datalogic instance , populates ui elements in view. when users enters data ui controller takes data ui elements , puts them in datalogic instance.

the controllers tie model different views. views never directly communicate model , vice versa. many different views can use same model , display different attributes of model merely writing new controller connect 2 together.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -