I am not familiar with transferring or passing data between two WKInterfaceController
in Apple Watch. What I am trying to do is , I have some variable like name
and age
in SecondInterfaceController
so I need to pass some value to them from WKInterfaceTable
when user tap a row . here is the code :
- (void)table:(WKInterfaceTable *)table didSelectRowAtIndex:(NSInteger)rowIndex {
NSString *name;
NSString *age;
switch (rowIndex) {
case 0:
name = @"Jack";
age = @"22";
break;
default:
break;
}
NSDictionary *d = [NSDictionary dictionaryWithObject:name forKey:@"kName"];
[self pushControllerWithName:@"SecondInterfaceController" context:d];
}
but I don't know how can I access to the dictionary from SecondIntefaceController and pass it to the _name (WKInterfaceLable) .
When you push your
SecondInterfaceController
it will haveawakeWithContext:
called on it and thecontext
parameter will be the dictionary you passed. Then you can pull the name value out of the context dictionary and assign it to your label.You can pass multiple values by adding multiple keys and values to your dictionary.