Syntax to access objects in my NSMutableArray

46 Views Asked by At

I have 2 objects in an NSMutableArray one is a CBPeripheral object and the other is an NSString.

Here you can see that the NSMutableArray contains the two objects: enter image description here

Then, in line 1249, I try to assign the 'periph' object to a CBPeripheral and in line 1252 I try to assign the 'ADVTname' to a text label.

Neither line 1249 nor 1252 is the correct syntax for what I am trying to do (line 1252 won't even compile).

Can someone tell me how to access my objects in my 'thisrow' NSMutableArray?

Thanks, Dale

EDIT #1: I am trying to understand how 'thisrow' has become an NSDictionay but I am stumped, here are all the code snippets that put the objects into 'thisrow'. Perhaps there is a flaw in the whole idea I have that is trying to remember the ADVTname for all peripherals that got added to _foundbleHalos.

//AFTER @interface foundblehalos was defined
@property (strong,nonatomic) NSMutableArray* foundbleHalos;

//in (void)centralManager > didDiscoverPeripheral
[_foundbleHalos addObject:@{@"periph": peripheral, @"ADVTname": ADVRTperipheralName}]; //2022-b70-3


//when I try to populate a TableView with all the ADVTnames we found:
NSMutableArray *thisrow = [_foundbleHalos objectAtIndex:indexPath.row];

blecell.textLabel.text = [NSString stringWithFormat:@"%@",thisrow.lastObject];

CBPeripheral* HaloForRow = (CBPeripheral*) thisrow[0];

EDIT #2: Well I think this following code is the answer to my topic question but I do not understand it since I do not know why 'thisrow' turned out to be a dictionary type when I originally defined it as an NSMutableArray:

//AFTER @interface foundblehalos was defined
@property (strong,nonatomic) NSMutableArray* foundbleHalos;

//in (void)centralManager > didDiscoverPeripheral
[_foundbleHalos addObject:@{@"periph": peripheral, @"ADVTname": ADVRTperipheralName}]; //2022-b70-3


//when I try to populate a TableView with all the ADVTnames we found:
NSDictionary *thisrow = [_foundbleHalos objectAtIndex:indexPath.row];

blecell.textLabel.text = thisrow[@"ADVTname"];

CBPeripheral* HaloForRow = (CBPeripheral*) thisrow[@"periph"];
0

There are 0 best solutions below