-1

我想使用字符串作为objectForkey. 我的代码行是这样的。

我想用“strend”作为一个objectForkey,但它没有用。

代码是:

NSString *strend = [[NSString alloc] initWithFormat:@"%@",[[detwec.arrdetails objectAtIndex:0]valueForKey:@"EndDate"]];

NSString *dateString = [[NSString alloc]initWithFormat:@"%@",[_currentItemValue objectForKey:@"strend" ]];
4

4 回答 4

0

尝试替换此行

NSString *dateString = [[NSString alloc]initWithFormat:@"%@",[_currentItemValue objectForKey:@"strend" ]];

这样

NSString *dateString = [[NSString alloc]initWithFormat:@"%@",[_currentItemValue objectForKey:strend]];
于 2012-11-16T11:27:57.053 回答
0

你可以试试

NSString *strend = [NSString stringWithFormat:@"%@",[detwec.arrdetails objectAtIndex:0]valueForKey:@"EndDate"];

NSString *dateString = [NSString stringWithFormat:@"%@",[_currentItemValue objectForKey:@"strend" ]];

要不然

NSString *dateString = [_currentItemValue objectForKey:@"strend" ];
于 2012-11-16T11:30:23.463 回答
0

NSString *strend = [NSString stringWithFormat:@"%@",[detwec.arrdetails objectAtIndex:0]]; NSUserDefaults *storeData=[NSUserDefaults standardUserDefaults];
[storeData setObject:strend forKey:@"strend"];
NSString *dateString = [storeData objectForKey:@"strend"];

于 2012-11-16T13:44:52.140 回答
0

如果要使用字符串作为键读取值,可以使用:

NSString *value = ["Your Dictionary" objectForKey:strend];

检查你的 NSString *strend 不应该是“nil”,否则不会给你任何价值。

于 2012-11-16T11:28:50.283 回答