Key Paths
来源:互联网 发布:单机版数据库 编辑:程序博客网 时间:2024/06/09 21:02
A key path allows you to chain keys in a single expression. If an object is key–value coding compliant for a certain key, and if the value of that key is itself an object that is key–value coding compliant for another key, you can chain those keys by calling valueForKeyPath: and setValue:forKeyPath:. A key path string looks like a succession of key names joined using dot-notation. For example, valueForKeyPath:@"key1.key2" effectively calls valueForKey: on the message receiver, with @"key1" as the key, and then takes the object returned from that call and calls valueForKey: on that object, with @"key2" as the key.
To illustrate this shorthand, imagine that our object myObject has an instance variable theData which is an array of dictionaries such that each dictionary has a name key and a description key. I’ll show you the actual value of theData as displayed by NSLog:
(
{
description = "The one with glasses.";
name = Manny;
},
{
description = "Looks a little like Governor Dewey.";
name = Moe;
},
{
description = "The one without a mustache.";
name = Jack;
}
)
Then [myObject valueForKeyPath: @"theData.name"] returns an array consisting of the strings @"Manny", @"Moe", and @"Jack". If you don’t see why, review what I said a few paragraphs ago about how NSArray and NSDictionary implement valueForKey:.
- Key Paths
- QuartzCore ->CATransform3D key paths->transform.translation.x
- Working with non-default SSH key pair paths
- Paths
- Paths
- Paths
- Paths
- Paths
- Paths
- Paths
- Paths
- Paths
- Paths
- Paths
- KEY
- Key
- KEY
- key
- 更新证书错误Code Sign error: Provisioning profile ‘XXXX'can't be found
- ENC28J60学习笔记——第3部分
- 基于XMPP协议(openfire服务器)的消息推送实现
- NYOJ-600-花儿朵朵-2013年08月21日19:14:49
- N皇后
- Key Paths
- C语言中字符串如何转换为二进制、八进制、十进制、十六进制
- 大学生活的完美句点
- 多线程和多进程的区别(小结)
- 如何利用Google机器人进行SQL攻击
- 音量调大时出现爆音的问题解决(也是从我的新浪博客转来的)
- Java 空指针异常(java.lang.NullPointerException)
- hibernate缓存
- NYOJ-2-括号配对问题-2013年09月09日09:32:18