objective c - variable becomes nil in numberOfRowsInTableView after being set in another method -
My class looks like this: I am using ARC for this project. Cocoa / Objective C Newbie here Any help would be much appreciated. Thank you updated - on the implementation of the class:
@interface ApplicantPickerController: AppPage & LT; NSTableViewDataSource, NSTableViewDelegate & gt; {School * school; __wake IBOutlet NSTableView * tableView; NSMutableArray * Family List; __weak IBOutlet NSProgressIndicator * Progress Indicator; } - (IBAction) Alphabet ButtonPressed: (ID) Sender; @end
in alphabetButtonPressed
method, I'm while getting a json array from a web service and to familyList
Describe. After doing this, I do [reload the tableView];
control passes to - (NSInteger) numberOfRowsInTableView: (NSTableView *) tableView
method, null
. Why is this happening and how can I fix it?
@interface ApplicantPickerController () @end @implementation ApplicantPickerController - (IBAction) alphabetButtonPressed :( ID) Sender {{Progress Indicator initialization: Self]; NSString * Addy = [[NSString alloc] initWithFormat: @ ".?% @ Work Php = applicant_lookup & amp; schoolID =% @ & amp; alpha =% @ & amp; currentYear =% @ & amp; format = json" , BASE_URL_SCHOOL, School & gt; Record id, [sender title], school-> current year]; NSURLRequest * Request = [NSRR request request with url: [NSD URL URL with string: AD]] ;; [NSURLConnection sendAsynchronousRequest: Request line: [NSOperationQueue mainQueue] completionHandler: ^ (NSURLResponse * reaction, NSData * data, NSError * error) {if (data) {// NSString * resp = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding ]; NSError * Error = Zero; NSObject * json = [NSJSONSerialization JSONObjectWithData: Data Options: NSJSONReadingAllowFragments Error: & amp; Error]; If ([Jayson HackandAfcla: [NSATO class]]) {Family List = zero; [Reload tableview data]; } And if ([Jason Is Kindoff's Class: [NSARRA class]]) {Family List = [[NSMUTABELARROR] INIT]; [Family List addObjectsFromArray: (NSArray *) json]; // [_ Family record]; [Reload tableview data]; } [Progress Indicator Stop Animation: Self]; }}]; } - (NSInteger) numberOfRowsInTableView: (NSTableView *) table view {return [family list count]; } - (id) initWithMainView: (NSView *) _ theView and MainController: (NSViewController *) _ theViewController andNibName: (NSString *) nibName AndArgs: (NSArray *) _ args {self = [super initWithMainView: _theView and main controller: _theViewControllerAndNibName: nibName AndArgs: _args]; School = [Args object auto index: 0]; Self return; } @end
I do not know if I got a bug by apple, but The following is the problem that I have solved this problem.
For some reason, if I were to code (especially > Set in awakeFromNib
method in delegate
and dataSource
), the problem is resolved.
- (zero) awakeFromNib {tableView.delegate = self; TableView.dataSource = self; }
Comments
Post a Comment