gpt4 book ai didi

iphone - 通过点符号访问 NSDictionary?

转载 作者:太空狗 更新时间:2023-10-30 03:35:24 26 4
gpt4 key购买 nike

有没有办法像这样通过点符号访问 NSDictionary 中键的值?

NSDictionary *returnVal = [NSDictionary dictionaryWithObjectsAndKeys:@"Saturn", @"name", @"Gas Giant", @"type", nil];
NSLog(@"VALUE: %@", [returnVal valueForKey:@"name"]); // This is how I am doing it now.

最佳答案

NSDictionary 没有点语法,但应该考虑使用 objectForKey: 而不是 valueForKey:

Difference between objectForKey and valueForKey?

关于iphone - 通过点符号访问 NSDictionary?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9264466/

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