Dynamic assigning of value to macro function .pch file and checking condition .pch file

独自空忆成欢 提交于 2019-12-10 11:27:21

问题


.pch as its name shows pre-compiler header, I have defined a macro in the file so that app can decide in the very beginning of the app compilation.

What I need is, possible to load any macro by assigning the values dynamically something like NSUserDefaults and checking the condition in .pch file itself.

If user disable logs from screen (switch), there should be no logs

else... it can print logs, least bother about Debug/Release mode.

I have " #define NSLog(FORMAT, ...) TFLog((@"%s [Line %d] " FORMAT), PRETTY_FUNCTION, LINE, ##__VA_ARGS__) " into my .pch file.

I am looking something like this :

#if REMOTEDEBUG_ENABLED   // CHECK FOR NSUserDefaults values and comparing for logs
" #define NSLog(FORMAT, ...) TFLog((@"%s [Line %d] " FORMAT), PRETTY_FUNCTION, LINE, ##__VA_ARGS__) "
#endif

Here is the reference link, but that assigning the value to macro from the project settings so didn't worked in my case.

I need to check the condition based on NSUserDefaults. Anybody, please let me, how I can achieve this OR any alternate where the app can decide either to print the logs/not using the macro. Thanks in advance !!!

来源:https://stackoverflow.com/questions/21275316/dynamic-assigning-of-value-to-macro-function-pch-file-and-checking-condition-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!