我想在选择 tableviewcell 后传递数据的属性。请指导我。我已经设置了 detailviewcontroller。DataArray 是我在 detailviewcontroller 中的可变数组。peripheralManager 是我的 NSbject。Peripheral 是我的设备。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
peripheralManager=[[PeripheralManager alloc]init];
self.MeBle.enabled=NO;
device=[[NSMutableArray alloc]init];
}
- (void)peripheralManagerDidConnectPeripheral:(PeripheralManager *)peripheral
{
NSLog(@"%@",peripheral.deviceName);
[device addObject:[NSString stringWithFormat:@" %@ ",peripheral.deviceName]];
// [device addObject:peripheral];
[self.deviceTable reloadData];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier=@"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if(cell==nil)
{
cell =[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text=[device objectAtIndex:indexPath.row];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//DetailViewController *detail=[self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];
// [self.navigationController pushViewController:detail animated:YES];
//[self performSegueWithIdentifier:@"TableDetails" sender:[device objectAtIndex:indexPath.row]];
}
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"TableDetails"]) {
DetailViewController *detail=segue.destinationViewController;
detail.dataArray=device;
}
}