• 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
Method Explanation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Method Explanation


  • Subject: Method Explanation
  • From: Kevin Ferguson <email@hidden>
  • Date: Fri, 11 Apr 2008 17:31:08 -0700

Greetings!

This is a rather odd (and I'm sure simple) question, but I cannot seem to find a suitable explanation anywhere I look.

So, my code initializes a menu with an action "myAction:", whose target is "myClass".

Now, I've noticed through trial and error that the only way to get my method to respond to the menu is to mark the method with a + as opposed to a -.
This means my method declaration is now +(void)myAction:(id)sender { }


So, this much I have working. Now, within that method, I programmatically create a panel and a few text boxes, along with a button with the action "doStuff" whose target is also "myClass". At the end of the method, I tell the panel to display, and everything, including the button, works fine. (An NSlog put in the doStuff: method activates) I noticed that the method that my button calls also must have the + to do anything.

However, the moment I try to access any of my objects (the button, or text boxes) that I created in the myAction: method, I get a warning saying that I'm accessing an instance variable from a class method, even though it is declared in the class's header file. As such, I can't really interact with it.

Now, I'm entirely self-taught in Cocoa, so this may be something more obvious than I think. Is there a reason for this occurrence? I assume it's got something to do with the +, but not knowing what the + means, or why my method must be a + to work, I can't really determine what to do. Can this be explained at all, or can anyone point me to a place that would explain it?

Thanks!
-Kevin
_______________________________________________

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: Method Explanation
      • From: Daniel Staal <email@hidden>
    • Re: Method Explanation
      • From: Michael Vannorsdel <email@hidden>
  • Prev by Date: Transparent view click-through
  • Next by Date: Re: Method Explanation
  • Previous by thread: Re: Transparent view click-through -- NOT SOLVED
  • Next by thread: Re: Method Explanation
  • Index(es):
    • Date
    • Thread