Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use FOUNDATION_EXPORT?

Tags:

objective-c

I am a bit confused as when we should use FOUNDATION_EXPORT in objective-c and what the purpose of that is? Can anyone explain in layman terms? Thanks!

like image 604
Jeremy Haning Avatar asked Oct 04 '13 23:10

Jeremy Haning


2 Answers

When we should use FOUNDATION_EXPORT in Objective-c

Whenever you are importing foundation framework in Objective-C. It is the best practice to use FOUNDATION_EXPORT instead of extern. Because NSObjCRuntime.h in Foundation framework it includes c and c++ library. So for default visibility of the c and c++ symbols it compiles accordingly for making it more compatible.

Purpose of using FOUNDATION_EXPORT instead of extern:

1) Visible Symbolity

2) Compatibility to other source code.

like image 113
Hussain Shabbir Avatar answered Oct 31 '22 14:10

Hussain Shabbir


When to use FOUNDATION_EXPORT?

Never.

FOUNDATION_EXPORT is an undocumented implementation detail of Apple's system frameworks so you should not use it at all.

like image 44
Nikolai Ruhe Avatar answered Oct 31 '22 14:10

Nikolai Ruhe