objective c - String substitution with variable constants -
this question has answer here:
- objective c macro append string 3 answers
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
Post a Comment