我正在开发Watch App,并且正在尝试将NSNumber传递给下一个控制器。
- (void)awakeWithContext:(id)context {
[super awakeWithContext:context];
NSNumber* test = (NSNumber*) [(NSDictionary*) context objectForKey:@"collId"];
}
但是,变量测试始终是“nil”,而上下文字典似乎包含值'(long)0'这是分配的值。
在这种情况下,在前面的控制器中添加为NSNumber *:
- (id) contextForSegueWithIdentifier:(NSString *)segueIdentifier inTable:(WKInterfaceTable *)table rowIndex:(NSInteger)rowIndex {
if ([segueIdentifier isEqualToString:@"segueList"]) {
DWCollRow* theRow = [table rowControllerAtIndex:rowIndex];
NSDictionary *userInfo = @{theRow.colId:@"collId"};
return userInfo;
}
return nil;
}
我做错了什么?
答案 0 :(得分:1)
对于此
NSDictionary *userInfo = @{theRow.colId:@"collId"}; //for this
@"Key" : @"Value"// you wrote this opposite
应该是
NSDictionary *userInfo = @{@"collId":theRow.colId};