私が読んだことから、NSMutableArray
オブジェクトが追加されます。
Student
オブジェクトを としてキャストせずに、特定の位置からオブジェクト変数を出力するにはどうすればよいですかStudent
。
Javaのようなものを探しているので、ArrayList<Student>
簡単に印刷できます.ArrayList.get(i).getName
ArrayList.get(i).getPrice
StudentRepository* myStudentRepo = [[StudentRepository alloc]init];
Student* myStudent = [[Student alloc]init];
myStudent.name = @"John";
// add a Student to the NSMutableArray
[myStudentRepo.studentRepository addObject:myStudent];
NSLog(@"Value: %@", myStudentRepo.studentRepository);
for(Student* myStudentItem in myStudentRepo.studentRepository)
{
NSLog(@"Value: %@", myStudentItem.name);
}
// print the Student from a given position
NSLog(@"Value: %@", [(Student*)[myStudentRepo.studentRepository objectAtIndex:0] name]);