Moving a PFObject value from a string into an array with counter

48 Views Asked by At

I am using ParseUI queries and PFQueryTableViewControllers. I have a PFQuerytable ViewController that needs to pass the value of the PFObject.objectId to another PFQUeryTableViewController. To do this I need to get that value into the prepare for seque method. I have been trying to add it to an array so that in the prepare for seque, I can use the IndexPath to retrieve the correct value and add it to the property on the receiving TVC.

However though I can get the value from object (PFObject) into a string when I try to simply move that value to an array element, using a counter, the result is a nil value in the array. I've been checking documentation and online etc and haven't been able to find why my array "objectIdArray" does not accept the value from objectIdString in the statement:

objectIdArray [i] = objectIdString;
@implementation LinesTableViewController


NSMutableArray *objectIdArray = nil;
int i = 0;
NSString *objectIdString = nil;


then inside method: cellForRowAtIndexPath

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
                        object:(PFObject *)object {
    static NSString *cellIdentifier = @"linesCell";
    
    PFTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[PFTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
                                      reuseIdentifier:cellIdentifier];}
    
    // Configure the cell
    
    cell.textLabel.text = object[@"name"];
    cell.detailTextLabel.text = [NSString stringWithFormat:@"Awesomness: %@ ",     object[@"rating"]];
    objectIdString = object.objectId;
    NSLog(@" heres the string %@", objectIdString);
    objectIdArray [i] = objectIdString;
    NSLog(@" heres the array %@", objectIdArray);
    i++;
1

There are 1 best solutions below

0
On
objectIdArray = [[NSMutableArray alloc] init];