# Swift and valueForKeyPath: You Can't Keep A Good API Down!

DevFeed: [Swift and valueForKeyPath: You Can't Keep A Good API Down!](<https://devfeed.tech/articles/swift-and-valueforkeypath-you-can-t-keep-a-good-api-down-37501.md>)

Original publisher: [Read original article](<https://www.cimgf.com/2014/11/05/swift-and-valueforkeypath-you-cant-keep-a-good-api-down/>)

Author: Matt Long

Published: 2014-11-05T19:43:51Z

Content type: tutorial

Language: en

Sources: [Cocoa Is My Girlfriend](<https://devfeed.tech/sources/cocoa-is-my-girlfriend.md>)

Topics: [Swift](<https://devfeed.tech/topics/swift.md>), [Objective-C](<https://devfeed.tech/topics/objective-c.md>), [coding](<https://devfeed.tech/topics/coding.md>)

Tags: [coding](<https://devfeed.tech/tags/coding.md>), [crash](<https://devfeed.tech/tags/crash.md>), [objective-c](<https://devfeed.tech/tags/objective-c.md>), [playground](<https://devfeed.tech/tags/playground.md>), [playgrounds](<https://devfeed.tech/tags/playgrounds.md>), [swift](<https://devfeed.tech/tags/swift.md>)

## AI overview

This tutorial explains how Swift's map can replace Objective-C's valueForKeyPath: for extracting properties from collections, including nested properties. It also compares Swift optional unwrapping with the more crash-resistant behavior of Foundation APIs when data is unpredictable.

## Source excerpt

tl;dr; Download the Value For Key Path Playground I was incredibly disappointed in Swift when I started to look into how key value coding might be preserved in the transition from Objective-C. Of course, Apple would preserve that, right? And I don't mean by resorting to using Foundation classes-you know all type-casty and everything (yeah, [...]