Static NSArray of strings - how/where to initialize in a View Controller

前端 未结 9 1938
甜味超标
甜味超标 2020-12-12 21:16

In a Master-Detail app I\'d like to display a TableView with 5 sections titled:

  1. Your Move
  2. Their Move
  3. Won Games
  4. Lost Games
  5. O
9条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-12 21:40

    You can also do something like this:

    static NSString * const strings[] = {
            [0] = @"string_1",
            [1] = @"string_2",
            [2] = @"string_3",
            [3] = @"string_4",
            // ...
        };
    

    It's not an NSArray but you can access NSStrings like this strings[n]

提交回复
热议问题