【问题标题】:View Parse Data on WatchKit Table在 WatchKit 表上查看解析数据
【发布时间】:2015-03-19 15:48:40
【问题描述】:

我正在尝试让我的应用在 WatchKit 上运行。我使用 Parse,并且想在我的 PFObject 中简单地将“请求”的值显示为 WatchKit 表中的一行。我已经设置了表和行,并且行 NSObject 类中只有 1 个标签,其中将填充“请求”字段。这是我在 Watch 的 InterfaceController 中的内容。

#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

如何从数组中获取该行的值到标签中?

【问题讨论】:

    标签: ios parse-platform watchkit wkinterfacetable


    【解决方案1】:

    我不太了解Objective C,但我有一个想法。 您需要从 ParseQuery 回调调用 setupTable 并将结果数组传递给它,或者在回调中迭代该数组并在每次迭代调用 mytable.label.setText(array[i]["property"])

    希望它有意义。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-11
      • 1970-01-01
      • 2017-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多