Where's the best place to store constants in an iOS app?

后端 未结 5 1578
忘了有多久
忘了有多久 2020-12-22 23:56

I\'m developing an app just now that fetches resources from a JSON API.

all of the resources have the same base URL:

http://api.mysite.com/resources.         


        
5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-23 00:39

    I just create a file called Globals.h with something like the following:

    #define kBaseURL @"http://api.mysite.com/"
    

    Then to use:

    #import "Globals.h" // at the top
    
    NSString *url = [NSString stringWithFormat:@"%@resources.json",kBaseURL];
    

提交回复
热议问题