Re: @class
Re: @class
- Subject: Re: @class
- From: Diederik Meijer | Ten Horses <email@hidden>
- Date: Fri, 22 Mar 2013 09:16:55 +0100
> The forward declaration is used to tell the compiler: "The word MyClass represents a class. I don't give you the implementation yet, but it represents a class, and the implementation will be provided later".
…and this allows you to create a property for an instance of that class in the .h that has the @class forward declaration. This way, you don't need to put #import class.h in there. You will need to include that last line in the .m in order for the property to work. So, in essence, you are putting your #import statement in the implementation and use the @class in the interface in order to reference its iVars in the .h
This is all done for performance reasons
Op Mar 21, 2013, om 10:20 PM heeft Jean Suisse <email@hidden> het volgende geschreven:
> A few minutes search gave me this. While I haven't taken a deep look to these resources, they do look good.
>
> - What's a forward declaration ? (several languages including Obj-C)
> http://en.wikipedia.org/wiki/Forward_declaration
>
> - When to use a forward declaration (C++):
> http://stackoverflow.com/questions/553682/when-to-use-forward-declaration
>
> - Objective C Programming Tutorial | Using @class And #import Directives
> http://www.youtube.com/watch?v=0b9Qok2uHhU
>
> @class allows you to declare a class.
> Example: @class MyClass;
>
> The forward declaration is used to tell the compiler: "The word MyClass represents a class. I don't give you the implementation yet, but it represents a class, and the implementation will be provided later".
>
> Jean
>
> On 21 mars 2013, at 21:43, H Miersch <email@hidden> wrote:
>
>> hi.
>>
>> what exactly does @class do?
>>
>> and what does "forward declaration" mean?
>> _______________________________________________
>>
>> 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
>
> _______________________________________________
>
> 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
>
_______________________________________________
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
References: | |
| >@class (From: H Miersch <email@hidden>) |
| >Re: @class (From: Jean Suisse <email@hidden>) |