• 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: Question about + & -
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about + & -


  • Subject: Re: Question about + & -
  • From: Gregory Weston <email@hidden>
  • Date: Thu, 13 Nov 2003 20:04:45 -0500

On Nov 13, 2003, at 16:00, Daniele wrote:

hello, I have a class with one connected NSTextField. A method inside
this class should permits to change the value of this field. Now I need
to call this method from different classes of my project, so I have
changed the method from - to + but unfortunatly there is a problem: i
cannot access to my NSTextField from the class method. Why? Can I solve
this problem without using the PostNotification method?

Because your connection is stored in an instance variable, and a class method doesn't receive a reference to an instance of that class so there's no instance variable to interact with. I think you may have misunderstood the implication of - and +. Class methods (+) are methods that operate on or on behalf of the class as a concept. Instance methods (-) operate on a specific instance of a class. They really don't have anything to do with whether the method can be invoked from elsewhere.

You've got two basic options. Change it back to an instance method, and make sure anything that wants to send the message knows about the instance, or leave it as a class method and let the class manage a singleton or default instance that it will manipulate when that message is received.

G
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Deprecated method documentation
  • Next by Date: "Warp" effect?
  • Previous by thread: Migrating to keyed archiving...?
  • Next by thread: "Warp" effect?
  • Index(es):
    • Date
    • Thread