handleWatchKitExtensionRequest限制

时间:2015-04-12 22:18:29

标签: ios objective-c watchkit

handleWatchKitExtensionRequest对您的行为有限制吗?我尝试从资源包中返回UIImage但我收到nil回复。

这有效:

-(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
{
    reply(@{@"Returning the number 1":@(1)});
}

这失败了:

-(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
{
    UIImage *image = [UIImage imageNamed:@"icon-152x152.png"];
    reply(@{@"image":image});
}

1 个答案:

答案 0 :(得分:3)

您传递的字典必须符合属性列表,这意味着您需要在发送之前将不是字符串,数字,字符串和数组的类转换为NSData。 How to convert UIImage to NSData.