gpt4 book ai didi

iphone - 从 NSDictionary 我只得到 0 或 null 我该怎么办?

转载 作者:行者123 更新时间:2023-11-28 23:12:17 25 4
gpt4 key购买 nike

这是我的代码

NSArray * alphabets = [NSArray arrayWithObjects:@"a",@"b",@"c",@"d",@"e",@"f",@"g",@"h",@"i",@"j",@"k",@"l",@"m",@"n",@"o",@"p",@"q",@"r",@"s",@"t",@"u",@"v",@"w",@"x",@"y",@"z",nil];
NSMutableDictionary * alphaToNum = [NSMutableDictionary dictionary];

NSInteger index =0;

for (NSString * character in alphabets) {

index++;
[alphaToNum setObject:character forKey:[NSNumber numberWithInteger:index]];
}

NSLog(@"%@",[alphaToNum objectForKey:@"d"]);

每次我尝试为我的 key 获取一些值时,我只得到 0 。

最佳答案

你需要...

NSLog(@"%@",[alphaToNum objectForKey:[NSNumber numberWithInteger:[alphabets indexOfObject:@"d"]]]);

关于iphone - 从 NSDictionary 我只得到 0 或 null 我该怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7874648/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com