---
title: "getObjectValue(_:for:range:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/dateformatter/getobjectvalue(_:for:range:)"
---

# getObjectValue(_:for:range:)

Returns by reference a date representation of a specified string and its date range, as well as a Boolean value that indicates whether the system can parse the string.

## Declaration

```swift
func getObjectValue(_ obj: AutoreleasingUnsafeMutablePointer<AnyObject?>?, for string: String, range rangep: UnsafeMutablePointer<NSRange>?) throws
```

## Parameters

- `obj`: If the receiver is able to parse string, upon return contains a date representation of string.
- `string`: The string to parse.
- `rangep`: If the receiver is able to parse string, upon return contains the range of string used to create the date.

## Discussion

Discussion note: In Swift, this method returns Void and is marked with the throws keyword to indicate that it throws an error in cases of failure. You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.

## See Also

### Related Documentation

- [string(for:)](foundation/formatter/string(for:).md)

### Converting Objects

- [date(from:)](foundation/dateformatter/date(from:).md)
- [string(from:)](foundation/dateformatter/string(from:).md)
- [localizedString(from:dateStyle:timeStyle:)](foundation/dateformatter/localizedstring(from:datestyle:timestyle:).md)
