通过点符号访问NSDictionary? [英] Access NSDictionary via dot notation?
本文介绍了通过点符号访问NSDictionary?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以通过点表示法来访问NSDictionary中的键值,像这样?
Is there a way via dot notation to access the values of keys in an NSDictionary like this?
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:
There is no dot syntax for NSDictionary
, but should consider using objectForKey:
instead of valueForKey:
objectForKey和valueForKey之间的区别?
这篇关于通过点符号访问NSDictionary?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文