Có cách nào để đúc các đối tượng trong mục tiêu-c giống như cách các đối tượng được đúc trong VB.NET không?Làm thế nào để đúc một đối tượng trong Objective-C
Ví dụ, tôi đang cố gắng để làm như sau:
// create the view controller for the selected item
FieldEditViewController *myEditController;
switch (selectedItemTypeID) {
case 3:
myEditController = [[SelectionListViewController alloc] init];
myEditController.list = listOfItems;
break;
case 4:
// set myEditController to a diff view controller
break;
}
// load the view
[self.navigationController pushViewController:myEditController animated:YES];
[myEditController release];
Tuy nhiên tôi nhận được một lỗi biên dịch vì 'danh sách' tài sản tồn tại trong lớp SelectionListViewController nhưng không phải trên FieldEditViewController mặc dù SelectionListViewController thừa hưởng từ FieldEditViewController.
Điều này có ý nghĩa, nhưng có cách nào để đưa myEditController vào một SelectionListViewController để tôi có thể truy cập thuộc tính 'danh sách' không?
Ví dụ trong VB.NET tôi sẽ làm:
CType(myEditController, SelectionListViewController).list = listOfItems
Thanks for the help!
Tìm kiếm "đúc" trên trang này: http://en.wikipedia.org/wiki/Objective-C –