<分区>
<分区>
当用户点击我的 UITableView
中的单元格时,我想将 sectionSelected
变量设置为该单元格的 indexPath.section
相应的部分,然后将该变量发送到 segue 中的下一个 View Controller 。
这是我目前正在尝试的方式:
MatchCenterViewController.h:
@property (assign, nonatomic) NSInteger *sectionSelected;
MatchCenterViewController.m:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Set _sectionSelected variable to the section index
self.sectionSelected = indexPath.section;
[self performSegueWithIdentifier:@"MCExpandedSegue" sender:self];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"MCExpandedSegue"]){
MCExpandedViewController *controller = (MCExpandedViewController *) segue.destinationViewController;
controller.sectionSelected = self.sectionSelected;
}
}
这是行不通的,看来这是因为我在行设置 self.sectionSelected
上收到以下警告:
从“NSInteger”(又名“long”)分配给“NSInteger *”(又名“long *”)的指针转换不兼容
如何正确设置变量?
最佳答案
改变
@property (assign, nonatomic) NSInteger *sectionSelected;
到
@property (assign, nonatomic) NSInteger sectionSelected;
关于ios - 如何将变量设置为所选单元格的 indexPath.section?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35023196/
相关文章:
ios - 每个测试版更新都需要通过 Apple TestFlight 批准吗?
ios - Xcode 中具有用户定义设置的程序中出现意外的 '@'
ios - 无法将参数传递给 UITableViewCell
objective-c - 是否可以以编程方式访问与我的 cocoa 绑定(bind)关联的 NSValueTransformer ?
ios - CollectionView 中单元格之间的间距
ios - 按下 tableView 单元格时在不同的 ViewController 中打开 URL
ios - selectRowAtIndexPath 在 viewWillAppear 中失败
iphone - 在 .m 文件中声明 Objective C 接口(interface)的实例变量(在 Release模式下)