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

前端 未结 9 1882
甜味超标
甜味超标 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:48

    You can init it in class method +initialize

    static NSArray *_titles_1;
    
    @implementation MasterViewController
    + (void)initialize {
        _titles_1 = @[
            @"Your Move",
            @"Their Move",
            @"Won Games",
            @"Lost Games",
            @"Options"
        ];
    }
    @end
    

提交回复
热议问题