iOS

通过宏定义从plist中读取配置

2017-03-11  本文已影响57人  kivinSun
#define  isConfigPathExist   [[NSFileManager defaultManager] fileExistsAtPath:[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Config.plist"] isDirectory:NO]
#define configPath [NSDictionary dictionaryWithContentsOfFile:[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Config.plist"]]

#define DEBUG_INNER isConfigPathExist?([[configPath objectForKey:@"DEBUG"] boolValue]):NO

#define DOCTORID isConfigPathExist? ([configPath objectForKey:@"DOCTORID"]) :nil```

通过上面DEBUG_INNER这个宏定义,就可以做到在Config.plist中的一个DEBUG值来决定是否是调试状态。 
通过上面DOCTORID这个宏定义,读取Config.plist中的字符串DOCTORID
上一篇下一篇

猜你喜欢

热点阅读