• 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
Obj-C, class methods and instance methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Obj-C, class methods and instance methods


  • Subject: Obj-C, class methods and instance methods
  • From: "Sanj W." <email@hidden>
  • Date: Sun, 19 May 2002 13:12:16 -0400

Hi,

Im trying to understand the difference between class methods and instance
methods in Obj-C. I thought that class methods are similar to static methods
in Java, where one could call the method without instantiating an class.

However, I could write the following class without a constructor (init) and
have an instance method (an IBAction) and get the system to call it (by
merely connecting in IB).

* How does this work? It would have made sense to me if myAction was
declared as a class method.

+(IBAction)myAction:(id)sender

* Is there a default constructor in in the following class that I declared?

<CODE IN QUESTION>

#import "MyClass.h"

@implementation MyClass

- (IBAction)myAction:(id)sender
{
//implementation...
}

@end

</CODE IN QUESTION>

Thanks,
Sanj
_______________________________________________
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.

  • Follow-Ups:
    • Re: Obj-C, class methods and instance methods
      • From: Chris Hanson <email@hidden>
    • Re: Obj-C, class methods and instance methods
      • From: Ondra Cada <email@hidden>
    • Re: Obj-C, class methods and instance methods
      • From: "Clark S. Cox III" <email@hidden>
  • Prev by Date: Window visiblity and Check Boxes
  • Next by Date: Re: Obj-C, class methods and instance methods
  • Previous by thread: Re: Window visiblity and Check Boxes
  • Next by thread: Re: Obj-C, class methods and instance methods
  • Index(es):
    • Date
    • Thread