我通过单击类SFAViewController中的按钮调用
-(IBAction)uploadselector:(id)sender // Notes and Attachments
{
SFAUploadController *uploadcontroller = [[SFAUploadController alloc] initWithNibName:@"SFAUploadController" bundle:nil];
//[SFAUploadController setRecordId:selectedrecordid];
[self.view addSubview:uploadcontroller.view];
[uploadcontroller setRecordId:selectedrecordid];
NSLog(@"Okay uploading.. with record id %@",selectedrecordid);
}
在类SFAUploadController中调用实例方法:-
-(void)setRecordId:(NSString *)value // called by SFAViewController.m
{
self.receivedrecordid = [[NSString alloc]initWithString:@"Empty"];
NSLog(@"Record value set");
//receivedrecordid = value;
}
-(IBAction)selectfile:(id)sender // called when a button clicked in SFAUploadController class
{
NSLog(@"Record in second class: %@",self.receivedrecordid); // causing program crash saying "(lldb)"
}
请解释一下为什么会这样?我不太熟悉将值引用从一个类传递到 iphone 中的另一个类。
谢谢。