• 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
Re: Pointers and NSImages
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pointers and NSImages


  • Subject: Re: Pointers and NSImages
  • From: Fritz Anderson <email@hidden>
  • Date: Thu, 2 Nov 2006 10:04:08 -0600

On 2 Nov 2006, at 9:37 AM, Lorenzo wrote:

I create my picture

    myPict = [[NSImage alloc] init...

Then many other objects use this picture.

    [rectangle usePicture:myPict];
    [circle usePicture:myPict];

When the user changes the picture I have to update the picture in all the
objects. Instead I would like to use pointers and avoid to relink all the
objects to the new picture all the time.

What you're saying is that you don't really want to track a particular picture object, but rather the myPict property of whatever object "owns" the picture. Solutions:


1. Define a notification type for a change-picture event, have the owning object post an NSNotification whenever its picture changes, and make the dependent objects observe the owner for that notification.

2. (10.3 and above) make the dependent objects key-value observers of the owning object, and make sure the owning object uses KVC accessors for the picture.

	— F

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Pointers and NSImages (From: Lorenzo <email@hidden>)

  • Prev by Date: Re: Open my Application via safari
  • Next by Date: Re: Open my Application via safari
  • Previous by thread: Pointers and NSImages
  • Next by thread: Re: Pointers and NSImages
  • Index(es):
    • Date
    • Thread