J'ai un MutableArray dans la classe NSObject je veux passer le NSMutableArray à detailViewController puis je veux afficher le NSMutableArray dans tableView (detailViewController) .Dans ce projet, j'ai un contrôleur à deux vues on est firstViewcontroller et detailviewcontroller.le problème est que les données ne peuvent pas passer de NSObject.Donnez-moi une idée si vous voulez plus d'informations S'il vous plaît demander.erreur en passant NSMutableArray de NSObject à ViewController
peripheralmanager.m
- (void)centralManager:(CBCentralManager *)central
didDiscoverPeripheral:(CBPeripheral *)peripheral
advertisementData:(NSDictionary *)advertisementData
RSSI:(NSNumber *)RSSI
{
NSLog(@"didDiscoverPeriphera.peripheral: %@ rssi: %@, UUID:%@ advertisementData:%@", peripheral,RSSI,peripheral.UUID, [advertisementData description]);
targetPeripheral = peripheral;
peripheral.delegate = self;
// [[centralManager retrievePeripherals:NSArray arrayWithObject:(id)peripheral.UUID] ];
// rssilabel.text=[RSSI stringValue];
if (!peripheral.isConnected)
{
[centralManager connectPeripheral:peripheral options:nil];
}
// MeBleAppDelegate *appdelegate=(MeBleAppDelegate *)[[UIApplication sharedApplication]delegate];
MeBleDetailViewController *obj=[[MeBleDetailViewController alloc]init];
// MeBleDetailViewController *obj=[[appdelegate sharedappdelegate].navigationController objectATindex:MeBleDetailViewController];
obj.dataArray=self.mutableArray;
[self.mutableArray addObject:peripheral];
printf("New UUId,addin\r\n");
}
detailviewcontroller.m
- (void)viewDidLoad
{
//NSMutableArray *dataArray=[[NSMutableArray alloc]init];
[super viewDidLoad];
NSLog(@"%@",self.dataArray);
NSLog(@"%@",objCurrentDevice.mutableArray);
// PeripheralManager *peripheralmanager=[[PeripheralManager alloc]init];
self.label.text=[NSString stringWithFormat:@" %@ ",dataArray];
// Do any additional setup after loading the view.
// [self.dataArray addObject:objCurrentDevice.mutableArray];
appDelegate.arrDevices=dataArray;
appDelegate = [[UIApplication sharedApplication] delegate];
// write below line in any function in this file
// NSLog(@"%d",[appDelegate.arrDevices count]);
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *[email protected]"Cell1";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if(cell==nil)
{
cell =[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text=[dataArray objectAtIndex:indexPath.row];
// PeripheralManager *objtemp=[[dataArray objectAtIndex:indexPath.row]deviceName];
NSLog(@"%@",objCurrentDevice.deviceName);
return cell;
}
Message d'erreur
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(0x356c888f 0x37a6f259 0x3561d1d7 0x164db 0x33135c8b 0x331421e9 0x33142059 0x33141f3f 0x331417c1 0x33141503 0x33135aff 0x331357d5 0x331ae903 0x33228627 0x351e2933 0x3569ca33 0x3569c699 0x3569b26f 0x3561e4a5 0x3561e36d 0x372ba439 0x3312acd5 0x1500f 0x14fb4)
terminate called throwing an exception(lldb)
Je veux sortie comme ceci image..Please Donner une idea..Please Ask Me pour plus d'informations.
je pense que '[self.mutableArray addObject: périphérique];' peut ajouter « néant » – BabyPanda
Combien de fois allez-vous poser la même question ? – Abizern
@Abizern Toujours en erreur J'ai essayé tant de façons. Ne vous mettez pas en colère cool. – prem