objective c - String substitution with variable constants -


this question has answer here:

in project, define urls such:

#define termsurl       @"http://127.0.0.1:8000/terms/" #define privacyurl     @"http://127.0.0.1:8000/privacy/" ... 

since root url (http://127.0.0.1:8000/) same, there way set constant, , use string substitution remaining pieces?

for example, in other files, this:

nsstring *devbaseurl = @"http://127.0.0.1:8000/"; nsstring *url1 = [nsstring stringwithformat:@"%@terms/", devbaseurl]; 

is there way current approach?

shared.h

#define termsurl       @"http://127.0.0.1:8000/terms/" #define privacyurl     @"http://127.0.0.1:8000/privacy/" #define url_base       @"http://127.0.0.1:8000/" 

yourclass.m

nsstring * stringurlbase = url_base; nsstring *url1 = [nsstring stringwithformat:@"%@terms/", stringurlbase]; 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -