• 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
Q's about Obj-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Q's about Obj-C


  • Subject: Q's about Obj-C
  • From: Joe Chan <email@hidden>
  • Date: Mon, 15 Oct 2001 11:23:20 -0400

I'm new to Cocoa/Obj-C (from the PP/C++ world), and I have some questions about the language itself:

1. When I'm defining the init method for my derived class, I read that I need to deal with [super init] returns nil. It's not entirely clear to me when that happens, who should dealloc the memory of the object? It doesn't seem right to me for the derived classes to deal with it, because if every derived class does it, there will be two many dealloc's chained together. The only place it seems sensible to dealloc is from the actual init method of the class that decides to return nil for some reason. Is that indeed the case?

2. It's not clear to me when I need to declare a method in the header file. From my reading of the Vermont Recipes at Stepwise, the language does not require me to declare methods in the header file if I override the super's method, or implement a delegate method. Does that mean the only time I need to declare a method in the header is when I introduce a new method to the class?

3. About the fact that all method of the same name needs to receive the same argument and return types. I'm a little confused by that. Does that apply only to the case of overriding existing method? Say if I have two classes A and B that belongs to different class hierarchies, and they both declare method foo:

@interface A : ParentOfA

-(int)foo: (float)arg;

@end

@interface B : ParentOfB
-(void)foo: (int)arg;
@end

Is this illegal? If so, how does one go about ensuring unique method names within a potentially large class hierarchy?

4. What makes a class an abstract class? In C++, that's caused by a pure virtual function, but there doesn't seem to an equivalent in Obj-C.

Thanks

-----------
Joe Chan
email@hidden
http://www.firstian.com


  • Follow-Ups:
    • Re: Q's about Obj-C
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: Changing hostname in Cocoa?
  • Next by Date: RE: Q's about Obj-C
  • Previous by thread: Re: Zooming in/out of images
  • Next by thread: Re: Q's about Obj-C
  • Index(es):
    • Date
    • Thread