---
title: decodeObject()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/nscoder/decodeobject()
---

# decodeObject()

Decodes and returns an object that was previously encoded with any of the encode…Object methods.

## Declaration

```swift
func decodeObject() -> Any?
```

## Discussion

Discussion NSCoder’s implementation invokes decodeValue(ofObjCType:at:) to decode the object data. Subclasses may need to override this method if they override any of the corresponding encode…Object methods. For example, if an object was encoded conditionally using the encodeConditionalObject(_:) method, this method needs to check whether the object had actually been encoded.

## See Also

### Related Documentation

- [encodeByrefObject(_:)](foundation/nscoder/encodebyrefobject(_:).md)
- [encodeBycopyObject(_:)](foundation/nscoder/encodebycopyobject(_:).md)
- [encode(_:)](foundation/nscoder/encode(_:)-9648d.md)

### Decoding General Data

- [decodeArray(ofObjCType:count:at:)](foundation/nscoder/decodearray(ofobjctype:count:at:).md)
- [decodeBool(forKey:)](foundation/nscoder/decodebool(forkey:).md)
- [decodeBytes(forKey:returnedLength:)](foundation/nscoder/decodebytes(forkey:returnedlength:).md)
- [decodeBytes(withReturnedLength:)](foundation/nscoder/decodebytes(withreturnedlength:).md)
- [decodeData()](foundation/nscoder/decodedata().md)
- [decodeDouble(forKey:)](foundation/nscoder/decodedouble(forkey:).md)
- [decodeFloat(forKey:)](foundation/nscoder/decodefloat(forkey:).md)
- [decodeCInt(forKey:)](foundation/nscoder/decodecint(forkey:).md)
- [decodeInteger(forKey:)](foundation/nscoder/decodeinteger(forkey:).md)
- [decodeInt32(forKey:)](foundation/nscoder/decodeint32(forkey:).md)
- [decodeInt64(forKey:)](foundation/nscoder/decodeint64(forkey:).md)
- [decodeObject(forKey:)](foundation/nscoder/decodeobject(forkey:).md)
- [decodePoint()](foundation/nscoder/decodepoint().md)
- [decodePoint(forKey:)](foundation/nscoder/decodepoint(forkey:).md)
- [decodePropertyList()](foundation/nscoder/decodepropertylist().md)
