我有一个 Save 方法,它应该保存在视图控制器的文本字段中输入的信息。该方法将此信息正确保存在类变量中,但我想将对象保存在数组中。当我尝试这样做时,我收到一个错误:
使用未声明的标识符“homeworkAssignment”;你的意思是“_homeworkAssignment”吗?
这是保存方法
- (IBAction)Save:(UIButton *)sender {
self.homeworkAssignment = [[Homework alloc] init];
self.homeworkAssignment.className = self.ClassNameField.text;
self.homeworkAssignment.assignmentTitle = self.AssignmentTitleField.text;
self.homeworkAssignment.assignmentDiscription = self.DiscriptionTextView.text;
self.homeworkAssignment.pickerDate = self.DatePicker.date;
NSArray *MyHomeworkArray = [[NSArray alloc]initWithObjects:homeworkAssignment, nil];
//Error here ^
}
谁能告诉我为什么我能够设置 homeworkAssignment 对象变量但在尝试将对象存储在数组中时出错?