문제

I would like to load different plist files based on what stage of the app (or profile) I am attempting to build...

For instance... in dev I want to add a plist that contains strings for our api on a dev server, in beta I want to add a plist that contains strings for our api on a bata server, etc.

What is the best way to do this?

Thanks.

도움이 되었습니까?

해결책

Prepare different plist file, and as VGruenhagen mentioned, use the Preprocessor Macros. You may want to do centralize into something like this:

+(NSString*)plistFileName {
#ifdef _DEV
    return @"data_beta.plist";
#elseif _BETA
    return @"data_beta.plist";
#else  // Release ?
    return @"data.plist";
#endif
}

다른 팁

The best way might not be using plist at all, if all you need is the string for your api.

You may want to look into the Configurations in Info and Preprocessor Macros in Build Settings. For example, you would want to create a Beta and Dev configuration.

Then you would want to set under the Macro for Beta, BETA = 1. While Dev would be DEV = 1.

In your code you would have a define if BETA is true and another for Dev that sets your string for your api. Once that is done all you would have to do is run project using the Dev or Beta Scheme depending which one you want.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top