2015-03-19 4 views
1

Я пытаюсь заставить мое приложение работать с WatchKit. Я использую Parse и хочу просто показать значение «Request» в моем PFObject как строку в таблице WatchKit. У меня есть таблица и строка, а класс NSObject просто имеет в нем 1 метку, где заполняется поле «Запрос». Вот что я имею в своем интерфейсе Controltroller для Watch.View Parse Data on WatchKit Table

#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 

Как получить значение из массива для этой строки в метку?

ответ

1

Я не очень понимаю цель C, но у меня есть идея. Вам нужно либо позвонить setupTable из обратного вызова ParseQuery и передать ему массив результатов, или либо перебирать этот массив в функции обратного вызова и в каждом итерацию вызова mytable.label.setText(array[i]["property"])

Надеется, что это имеет смысл.