I have declared this ivar in my
ViewController.h
#import
@interface FirstViewController : UIViewController
NSArray *sortedCountries = [[countries sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]]retain];
to
self.sortedCountries = [countries sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]];
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.