Re: Replacing objects
Re: Replacing objects
- Subject: Re: Replacing objects
- From: Ken Thomases <email@hidden>
- Date: Mon, 22 Dec 2008 16:52:10 -0600
On Dec 22, 2008, at 4:09 PM, DAS wrote:
Is it possible to replace an object with another object so that all
pointers
to that object now point to the new object?
No. There are techniques you can use to achieve something similar,
but I think the real problem is with your design. If you're asking
this question, it means there's something wrong.
The reason I'm trying to do this is that I have a number of
NSMutableArray's
throughout my application whose contents are based off a database on a
server.
Having these arrays "throughout" your application suggests that you
haven't got a proper model in your design.
The model is responsible for both holding your data and manipulating
it according to your app's "business" or "domain" logic. The model is
responsible for always presenting a coherent view of your app's or
document's state.
Periodically, the user searches the database, which returns a list
of objects. Some of these objects the client already has, and in
that case I
would like to replace the local object with the one I've created via
the
server.
Updating like this is part of the model responsibilities I described
above. It should all happen within the model and under the control of
the model. If other parts of your app outside of the model need to
mirror that data (for example, in a cache) then those other parts need
to register themselves as observers on the appropriate properties of
the model so that they will be notified when that data changes.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden