我得到了在iOS版继承一个UIViewController困惑,我有这符合了UICollectionViewDataSource协议(在实现文件内的专用接口),父视图控制器。子类的UIViewController iOS中
/* Parent.m */
@interface Parent() <UICollectionViewDataSource>
// this CollectionView is connected to storyboard
@property (weak, nonatomic) IBOutlet UICollectionView *CollectionView;
@end
@implementation Parent
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.somecount;
}
@end
然后我创建一个子视图控制器,它从父类继承。孩子对UICollectionViewDataSource一无所知,因为它是父母专用接口中实现的数据源。
/* child.h */
@interface child : parent
// nothing was mentioned here that parent has a method to set the count using 'somecount'
@end
然后我从mainstoryboard设置视图控制器作为子视图控制器。
是怎么来的ios得到父母的财产“somecount”的价值,并为孩子的价值?
谢谢。
感谢罗布,我试图调试应用程序,它会在第一行是父: @property(弱,非原子)IBOutlet中UICollectionView *的CollectionView; 我认为它可以为父母中的私有财产设置价值的原因是因为故事板知道collectionView是父类的出口。 有无论如何调试故事板上的代码,以便我可以找出起点和步骤的详细流程。 谢谢。 – Justin
让我明确我的问题: 1.如何找出从应用程序开始调用的代码流,以任何方式从故事板一开始就进行调试?即初始化故事板 - 初始化集合视图 - 初始化集合视图的控制器 - 或初始化父母? 2.您提到“底线,孩子会自动继承父级的所有行为,方法和属性。”这是否意味着子类将拥有私有属性(在父级中声明)?但孩子在编译时无法访问它们?我怎么不能访问我自己的财产? – Justin
这里是链接:http://www.stanford。埃杜/班/ cs193p/cgi-bin目录/ Drupal的/系统/文件/ sample_code /漂亮%20Matchismo.zip 看看在CardGameViewController和PlayingCardGameViewController, 感谢 – Justin