---
title: "insertValue(_:inPropertyWithKey:)"
framework: objectivec
role: symbol
role_heading: Instance Method
path: "objectivec/nsobject-swift.class/insertvalue(_:inpropertywithkey:)"
---

# insertValue(_:inPropertyWithKey:)

Inserts an object in the collection specified by the passed key.

## Declaration

```swift
func insertValue(_ value: Any, inPropertyWithKey key: String)
```

## Discussion

Discussion The method insertIn<Key>: is used if it exists. Otherwise, raises an NSUndefinedKeyException. This is part of Cocoa’s scripting support for inserting newly-created objects into containers without explicitly specifying a location.

## See Also

### Access by name, key, or ID

- [value(withName:inPropertyWithKey:)](objectivec/nsobject-swift.class/value(withname:inpropertywithkey:).md)
- [value(withUniqueID:inPropertyWithKey:)](objectivec/nsobject-swift.class/value(withuniqueid:inpropertywithkey:).md)
