user717452
user717452

Reputation: 111

View Parse Data on WatchKit Table

I am trying to get my app working on WatchKit. I use Parse, and want to simply show the value of "Request" in my PFObject as a row in a WatchKit Table. I have the table and row set up and the row NSObject class simply has 1 label in it, where the "Request" field will populate. Here is what I have in my InterfaceController for the Watch.

#import "InterfaceController.h"
#import "TheTable.h"
#import <Parse/Parse.h>
#import "BlogView.h"
@interface InterfaceController()
@property (nonatomic, retain) PFObject *theObject;
@property (nonatomic, retain)     NSMutableArray *rowTypesList;

@end


@implementation InterfaceController
- (void)awakeWithContext:(id)context {
    [Parse setApplicationId:@"MYID"
                  clientKey:@"MYKEY"];

    [super awakeWithContext:context];

    // Configure interface objects here.
}

- (void)willActivate
{
    PFQuery *query = [PFQuery queryWithClassName:@"Prayers"];

    // If no objects are loaded in memory, we look to the cache first to fill the table
    // and then subsequently do a query against the network.


    [query orderByDescending:@"createdAt"];


    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {

            NSArray *array = [objects objectAtIndex:0];//Selects the first "object" from all the "objects"
            array = [array valueForKey:@"Request"];//Makes a NSArray from the "pairs" values
            _rowTypesList = [array mutableCopy];//Converts the array to a NSMutableArray

            NSLog(@"%@",  _rowTypesList);
        } else {
            // Log details of the failure
            NSLog(@"Error: %@ %@", error, [error userInfo]);
        }
    }];    [self setupTable];
}

- (void)setupTable
{

    NSLog(@"%@", _rowTypesList);

    [_theActualTable setRowTypes:_rowTypesList];

    for (NSInteger i = 0;_theActualTable.numberOfRows; i++)
    {

        NSObject *row = [_theActualTable rowControllerAtIndex:i];
            TheTable *importantRow = (TheTable *) row;
            [importantRow.textRowLabel setText:???]; //THIS IS PROBLEM AREA, HOW DO I GET TEXT HERE FROM THE MUTABLEARRAY

    }
}

@end

How do I get the value from the array for that row into the label?

Upvotes: 1

Views: 225

Answers (1)

alexbuga
alexbuga

Reputation: 21

I don't understand Objective C that much, but I get an idea. You need to either call setupTable from the ParseQuery callback and pass it the results array, or either iterate that array in the callback and in each iteration call mytable.label.setText(array[i]["property"])

Hope it makes sense.

Upvotes: 1

Related Questions