Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 04-21-2009, 01: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
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,345
Threads: 39,137
Posts: 171,594
Top Poster: smasher (2,577)
Welcome to our newest member, lewissmile
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:19 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.