简体   繁体   English

如何在xcode项目中更新URL,而无需再次构建应用程序?

[英]How to update a URL in xcode project without having to build the application again?

I have an application which hits the server for communication. 我有一个可以与服务器通信的应用程序。 In case, my server address changes, i want to incorporate that changed address in the application from the device itself. 万一我的服务器地址发生了变化,我想将更改后的地址从设备本身合并到应用程序中。

I dont want to build my application again and sync it with itunes and then with my device. 我不想再次构建我的应用程序,并使其与iTunes,然后与我的设备同步。 As an administrator, i want to update the url from outside. 作为管理员,我想从外部更新URL。

I would suggest using NSUserDefaults and a Settings Bundle to modify the URL. 我建议使用NSUserDefaults和设置包来修改URL。 It would then be a user preference which can have a sensible default, but then can be changed from outside the app without recompilation. 这将是一个用户首选项,可以具有合理的默认值,但是可以在不重新编译的情况下从应用程序外部进行更改。 See the "Implementing Application Preferences" section of Apple's iOS Application Programming Guide. 请参阅Apple的iOS应用程序编程指南中的“实现应用程序首选项”部分。

If my comment to Christian's answer is valid, why don't you use an actual domain name instead of a server address? 如果我对Christian的回答的评论是正确的,为什么不使用实际域名而不是服务器地址? Then it doesn't matter if your IP changes. 然后,无论您的IP是否更改,都没有关系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM