Instance variable not retaining value in iOS application

后端 未结 2 1614
遇见更好的自我
遇见更好的自我 2021-01-24 07:33

I have declared this ivar in my

ViewController.h

#import 

@interface FirstViewController : UIViewController 

        
2条回答
  •  春和景丽
    2021-01-24 07:58

    You are re-declaring sortedCountries as a local variable in viewDidLoad. Use:

    sortedCountries = ...
    

    instead (notice no NSArray *). In the code you are using now, sortedCountries would be populated in viewDidLoad, but accessible only in viewDidLoad. You were creating a new variable with the same name instead of setting the class property.

提交回复
热议问题