0

我一直想知道如果他们可能会改变人们如何管理他们的字符串?

就像...您是否硬编码,使用属性列表或字符串文件?还有其他方法吗?

4

2 回答 2

3

It actually depends on the type of strings, I'll give some examples:

  1. UI strings -> Put them into Localizable.strings and use NSLocalizedString macro.
  2. Server URL -> hardcode (meaning to put them into a separate header) or specify them as build parameter.
  3. Parsing strings (e.g. keys for JSON dictionaries) -> hardcode
  4. App is based on text strings (e.g. Dictionary App) -> Database
于 2012-06-11T09:01:49.347 回答
0

If they are to be used in the classes such as for notifications and/or for dictionary keys you would define them

 #define MYOWN_NOTIFICATION @"NotifySth"
    #define CITY_KEY @"city"

If you are going to have a small collection of strings then a plist would be the way to go You will then use it to load it inside an NSDictionary or NSArray

If you have a large collection of strings then store them in a db and query the string basing on your own criteria

于 2012-06-11T09:01:19.623 回答