Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-27-2009, 10:07 PM   #26 (permalink)
Goon (on a good day)
 
Join Date: Apr 2009
Location: California
Posts: 55
Default

Quote:
Originally Posted by exorcyze View Post
*iPityTha = (Foo *)
llloooloololllllololl.
coondog is offline   Reply With Quote
Old 04-28-2009, 12:55 AM   #27 (permalink)
New Member
 
Join Date: Nov 2008
Posts: 123
Default

Quote:
Originally Posted by exorcyze View Post
Well it's nothing terribly magical, and I'll assume that anyone reading this can parse out the header vs module code and that stubs of course have code in them, but maybe this will help the idea:

>snip
Got it!

It seems as there 4 stages of evolution of the Model.

1) Define data in the View/VC that uses it (or anywhere else that makes sense) -- works for examples and simple apps.
2) Load up the appDelegate with data definitions and the methods to manipulate them-- where I am.
3) refactor the Model definition/methods out to separate class(es)-- where exorcyze is.
4) design speciality classes to:
---- define the data (the model)
---- define the methods (and external interfaces) that act on the data (the Model Controller)
where eddietr is.

What is interesting is that (in 3 and 4) the appDelegate becomes the point-guard (distributing the ball) without being overloaded with unnecessary complexity (neither are the VCs or the Views).

i think I like this... It makes sense... I can implement as much (or as little) as I want to support a specific app, without feeling like I am going down a bad-practices blind alley.

As with all things, it is better to understand both ends of the spectrum when deciding to implement a technique.

exorcyze-- thanks for sharing your work... it really helps to show the way!

eddietr-- look forward to your tutorial/solution... I may not need to implement it for every app, but (hopefully) I can code even my most basic apps in such a way that they can easily be extend to a Model/Model Controller implementation.

Realistically. if the eddietr solution is not too expensive, I will implement it in every app for reasons of consistency, standardization and ease-of maintenance.

Thanks, guys!

Dick
dicklacara is offline   Reply With Quote
Old 04-28-2009, 08:37 AM   #28 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 495
Default

Just to clarify - I still have seperate model classes broken out. I also have a controller to manage the collections of those, and a controller for managing the marriage of those data collections to the database.

From what it sounds like to me, the primary difference in my approach from what eddietr is doing is that I have the last two combined ( collections and data access methods for populating them ), and I don't have a layer for managing proxies etc. My data connections were local in this case, so I didn't need any additional level of complexity in there. =)
__________________
My Apps on AppStore : gScale (guitar scales reference), eMaze, eMaze Lite, eTimesheet
exorcyze is offline   Reply With Quote
Old 04-28-2009, 10:15 AM   #29 (permalink)
New Member
 
Join Date: Nov 2008
Posts: 123
Default

Quote:
Originally Posted by exorcyze View Post
Just to clarify - I still have seperate model classes broken out. I also have a controller to manage the collections of those, and a controller for managing the marriage of those data collections to the database.

From what it sounds like to me, the primary difference in my approach from what eddietr is doing is that I have the last two combined ( collections and data access methods for populating them ), and I don't have a layer for managing proxies etc. My data connections were local in this case, so I didn't need any additional level of complexity in there. =)
Thanks for clarifying-- I went back and reread your post.

It appears that your approach will do the job nicely for most apps.

Thinking out loud here:

I started out (following many of the examples) putting my model definition/data/methods in the View Controllers where they were first needed.

Later, frustrated by the difficulty of accessing them from other places in the app and spurred by the need to save and restore data at termination and startup, I moved the model to the appDelegate.

This works fine, except it kinda' feels wrong-- too abstract, and the appDelegate gets humongous & confusing in an app that uses multiple classes of data.

That's where I am today.

The next logical step in the evolution of my apps will, likely, be to your approach.

Again, this should suffice for most apps.

I also have a need to periodically update/synch the model to/from an external source. This could range from several times per hour to one time per day.

From his description, it appears as if eddietr has a solution that handles real-time dynamic data (stock market quotes, baseball scores, multiplayer games states, etc.).

While this is more capability than I currently need, I can see advantages to using such an approach. It should be able to handle the periodic update/synchs with ease.

I am interested in seeing the eddietr solution. While it may be overkill for most apps, it will be useful to understand what is required to deal with "live" data.

TIA

Dick
dicklacara is offline   Reply With Quote
Old 04-28-2009, 10:32 AM   #30 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 495
Default

Yup, if I needed something more robust than simple data access ( caching, etc ) then I would just either put another layer in for the retreival of the data that would handle it, or have some helper classes that those methods use ( if it needed to be on a case-by-case basis ).

=)
__________________
My Apps on AppStore : gScale (guitar scales reference), eMaze, eMaze Lite, eTimesheet
exorcyze is offline   Reply With Quote
Old 04-28-2009, 12:18 PM   #31 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 6
Default

Just wanted to say a quick thanks to coondog for starting this thread, and eddietr, exorcyze, and dicklacara for all the information. This has been one of the best aids I've had in iPhone programming so far.

I've been muddling for a few weeks through exactly these same sorts of questions, and struggling through exactly the progression of data-model sophistication that dicklacara described.
natekruser is offline   Reply With Quote
Old 05-05-2009, 12:17 AM   #32 (permalink)
New Member
 
Join Date: Apr 2009
Posts: 13
Default

I was just pointed to this thread from another one and curious to find out if someone was going to do a short tutorial on this.

Great thread!
Retnuh is offline   Reply With Quote
Old 05-05-2009, 01:33 PM   #33 (permalink)
Developer
 
Nosferatu's Avatar
 
Join Date: Jan 2009
Posts: 16
Default

Check out lecture 7 of the Stanford CS193P course which is run by Apple engineers.

CS193P - Cocoa Programming | Announcements

They talk about best practices for data flow within your application and specifically, between view controllers. In short, using the application delegate, global variables and singleton methods are all bad practices. Instead, communicate only the data that needs to be communicated to the next view controller via properties or custom initializer methods in the view controller that is being pushed onto the stack.
__________________
Avatar Credit: M. Uli Kusterer
Nosferatu is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 253
23 members and 230 guests
ADY, bookesp, chillyh, ckgni, dacapo, Dani77, Davey555, Desert Diva, glenn_sayers, HemiMG, JasonR, LEARN2MAKE, M.A.S., marshusensei, mer10, nobre84, prchn4christ, Raggou, Rudy, ryantcb, themathminister, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,765
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:35 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0