ios - 查看 WatchKit 表上的解析数据

标签 ios parse-platform watchkit wkinterfacetable

我正在尝试让我的应用程序在 WatchKit 上运行。我使用 Parse,并想简单地将我的 PFObject 中“Request”的值显示为 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

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

最佳答案

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

希望它有意义。

关于ios - 查看 WatchKit 表上的解析数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29149146/

相关文章:

Android Parse SDK - 保护凭据

ios swift parse.com : How can I select data from multiple objects?

ios - 从 Watch 应用程序调用父应用程序时如何使用文件加密?

ios - 我如何保证主机应用程序和扩展程序使用的共享应用程序容器中核心数据存储中的唯一条目?

iphone - 你可以在 MKMapView 中使用 iOS 6 3D 按钮吗?

ios - 如何在 InfoWindow 中包含一个按钮

iphone - 如何检查用户的 iOS 设备是否支持蓝牙点对点连接

ios - 为什么需要覆盖 layoutSubviews

android - 在解析中,发送的推送始终为 0

ios - Apple Watch 中的陀螺仪和加速度计