• 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: Warnings that won't go away
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Warnings that won't go away


  • Subject: Re: Warnings that won't go away
  • From: Sherm Pendley <email@hidden>
  • Date: Wed, 30 Nov 2005 12:02:49 -0500

On Nov 30, 2005, at 8:07 AM, Tom Jones wrote:

What's the difference between
the @class directive and the #import directive...when should I use one
and not the other? I was using @class, and getting warnings. Do I need
to use #import when I am calling specific methods of my class, and use
@class when I want to instantiate a member variable of a particular
class?

That's basically it. @class tells the compiler that the named class exists, but nothing else about it. It doesn't tell the compiler about the class' methods.


One common usage is to use @class in header files. When you're declaring instance variables, arguments, and return types, knowing that a class exists is sufficient. Then, in your .m file, you'd use #import to get the full definition of the class, so that you can call its methods.

This helps to minimize dependencies and keep build times to a minimum. If you #import Playlist.h in Song.h, then any file that #imports Song.h will also depend on Playlist.h, and will need to be recompiled if Playlist.h is edited. But, if you use @class in Song.h, then Song.h will no longer depend on Playlist.h - and neither will the files that #import Song.h.

sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

_______________________________________________
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: 
 >Warnings that won't go away (From: Tom Jones <email@hidden>)
 >Re: Warnings that won't go away (From: Sherm Pendley <email@hidden>)
 >Re: Warnings that won't go away (From: Tom Jones <email@hidden>)

  • Prev by Date: Re: Finding the error...
  • Next by Date: Re: Warnings that won't go away
  • Previous by thread: Re: Warnings that won't go away
  • Next by thread: Re: Warnings that won't go away
  • Index(es):
    • Date
    • Thread