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

View Single Post
Old 04-21-2009, 02:21 PM   #13 (permalink)
eddietr
Registered Member
 
Join Date: Apr 2009
Posts: 536
Default

Quote:
Originally Posted by p.witty View Post
An idea I've had -- but have not yet tried -- is to put these instances into appropriate static class vars. That is, to make instance-aware classes, so I can do something like this:

User currentUser = [User currentUser];
Yeah, so that's the classic singleton pattern, with access through a class method. Only issue is you can't have an actual class var in ObjC, so you have use global variables instead. Not a huge deal.

Quote:
Or even more generically,

NSArray myUsers = [User findByName:@"Joe Bob"];
So that's just a static method that would find instances as needed. With the "class variable" in this case being an array of model instances. So it's a little different, but still would work nicely.

Quote:
I'm not sure whether it would be better to have something which would differentiate between in-memory models and in-db models:

[User findInMemByName:@"Joe Bob"];
[User findInDbByName:@"Joe Bob"];

Or if it would be better to make it generic:

[User findByName:@"Joe Bob"];
So the latter ("generic", as you called it) approach is how I would generally do this. But it all depends on your project of course.
eddietr is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,746
Threads: 89,201
Posts: 380,567
Top Poster: BrianSlick (7,129)
Welcome to our newest member, raKinesic
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:07 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.