Xcode 4 can’t locate public header files from static library dependency

Each of the solutions I’ve seen to this problem have either seemed inelegant (copying headers into the application’s project) or overly simplified to the point that they only work in trivial situations. The short answer Add the following path to your User Header Search Paths “$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts” Why does this work? First, we need to understand … Read more

#define in Java

No, because there’s no precompiler. However, in your case you could achieve the same thing as follows: class MyClass { private static final int PROTEINS = 0; … MyArray[] foo = new MyArray[PROTEINS]; } The compiler will notice that PROTEINS can never, ever change and so will inline it, which is more or less what … Read more

Preprocessor directives in Razor

I just created an extension method: public static bool IsDebug(this HtmlHelper htmlHelper) { #if DEBUG return true; #else return false; #endif } Then used it in my views like so: <section id=”sidebar”> @Html.Partial(“_Connect”) @if (!Html.IsDebug()) { @Html.Partial(“_Ads”) } <hr /> @RenderSection(“Sidebar”, required: false) </section> Since the helper is compiled with the DEBUG/RELEASE symbol, it works.

How to convert an enum type variable to a string?

The naive solution, of course, is to write a function for each enumeration that performs the conversion to string: enum OS_type { Linux, Apple, Windows }; inline const char* ToString(OS_type v) { switch (v) { case Linux: return “Linux”; case Apple: return “Apple”; case Windows: return “Windows”; default: return “[Unknown OS_type]”; } } This, however, … Read more