ios - object becomes null when passed to another view controller -


in ios application, need pass object 1 view controller , switch new view controller. goal relay information. however, object becomes null , devoid of information when next view showed up. what? reason?

below part of code.

#pragma mark - table view delegate  -(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {    bidcourse *course = self.courses[indexpath.row];      nsstring *sub = course.subject;     bidsubjectmaintwoviewcontroller *subjectcontroller=[[bidsubjectmaintwoviewcontroller alloc] init];     subjectcontroller.title = sub;      subjectcontroller.course=course;     [self.navigationcontroller pushviewcontroller:subjectcontroller animated:yes]; } 

bidcourse *course custom subclass nsobject, has nsstrings, , it's not nil, when pass onto next view controller, becomes null.

i have met problem , when pass object viewcontroller , has been released.

i think defect of arc , arc think subjectcontroller may no use , release subjectcontroller. make subjectcontroller property , arc not release when pass viewcontroller.

such :

#pragma mark - table view delegate  -(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { bidcourse *course = self.courses[indexpath.row];   nsstring *sub = course.subject;  _subjectcontroller=[[bidsubjectmaintwoviewcontroller alloc] init];  _subjectcontroller.title = sub;   _subjectcontroller.course=course;  [self.navigationcontroller pushviewcontroller:_subjectcontroller animated:yes]; } 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -