简体   繁体   中英

iOS - 2 projects in a workspace and referencing the same files - how to determine which project I am in?

I currently have 2 projects in a workspace. The files are being referenced from Project A to Project B. My question is what is the cleanest way to determine which project I am in. For instance, I want to use ViewController1 (VC1) for both apps.

Thinking of this with a generic boolean. If I am in project A show this, else show this...

我认为这种情况永远不会发生,直到现在为止都没有听说过。

You might be able to do it with command line preprocessor definitions. If you can define _PROJECT_A_ on one, and _PROJECT_B_ on the other, you could do something like:

#if defined(_PROJECT_A_)
    // do project A things
    static const BOOL ProjectBMode = NO;
#elif defined(_PROJECT_B_)
    // do project B things
    static const BOOL ProjectBMode = YES;
#endif

Or use other #define s instead of a BOOL . See this thread .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM