• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Replacing objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Replacing objects


  • Subject: Replacing objects
  • From: DAS <email@hidden>
  • Date: Mon, 22 Dec 2008 17:09:02 -0500

Hey guys, I'm fairly new to cocoa development here, so please bear with me.
Is it possible to replace an object with another object so that all pointers
to that object now point to the new object? In other words:
Ptr A -> object1
Ptr B -> object1
Ptr C -> object1

I want to replace object1 with another object (of the same type), so that
all my pointers now point to object2. I realize that I could manually
replace all of the internal data in the object, thus leaving the pointer
intact, but I was hoping that there would be an easier way.

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. 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. I've implemented an NSDictionary that holds all of the objects that
have come in from the server, and each NSMutableArray points to those same
objects (they are all subsets of the main list). This works fine except for
in the case where an existing object comes in from the server. I'd like to
be able to replace the original object with my new one and retain all of
it's pointers.

Thanks for the help,
Dimitri
_______________________________________________

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

  • Follow-Ups:
    • Re: Replacing objects
      • From: Ken Thomases <email@hidden>
  • Prev by Date: NSString property: copy or retain?
  • Next by Date: Re: Drawing in a NSView out side of drawRect
  • Previous by thread: Re: NSString property: copy or retain?
  • Next by thread: Re: Replacing objects
  • Index(es):
    • Date
    • Thread