我想将字符串用作objectForkey
。我的代码行是这个。
我想将“strend”用作objectForkey
,但它不起作用。
代码是:
NSString *strend = [[NSString alloc] initWithFormat:@"%@",[[detwec.arrdetails objectAtIndex:0]valueForKey:@"EndDate"]];
NSString *dateString = [[NSString alloc]initWithFormat:@"%@",[_currentItemValue objectForKey:@"strend" ]];
答案 0 :(得分:0)
尝试替换此行
NSString *dateString = [[NSString alloc]initWithFormat:@"%@",[_currentItemValue objectForKey:@"strend" ]];
由此
NSString *dateString = [[NSString alloc]initWithFormat:@"%@",[_currentItemValue objectForKey:strend]];
答案 1 :(得分:0)
如果你想使用字符串作为键读取值,你可以使用:
NSString *value = ["Your Dictionary" objectForKey:strend];
检查你的NSString * strend不应该是“nil”否则不会给你任何价值。
答案 2 :(得分:0)
你可以尝试
NSString *strend = [NSString stringWithFormat:@"%@",[detwec.arrdetails objectAtIndex:0]valueForKey:@"EndDate"];
NSString *dateString = [NSString stringWithFormat:@"%@",[_currentItemValue objectForKey:@"strend" ]];
或者
NSString *dateString = [_currentItemValue objectForKey:@"strend" ];
答案 3 :(得分:0)
NSString * strend = [NSString stringWithFormat:@“%@”,[detwec.arrdetails objectAtIndex:0]]; NSUserDefaults * storeData = [NSUserDefaults standardUserDefaults];
[storeData setObject:strend forKey:@“strend”];
NSString * dateString = [storeData objectForKey:@“strend”];