---
title: hash
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/nsstring/hash
---

# hash

An unsigned integer that can be used as a hash table address.

## Declaration

```swift
var hash: Int { get }
```

## Discussion

Discussion If two string objects are equal (as determined by the isEqual(to:) method), they must have the same hash value. This property fulfills this requirement. You should not rely on this property having the same hash value across releases of macOS.

## See Also

### Identifying and Comparing Strings

- [caseInsensitiveCompare(_:)](foundation/nsstring/caseinsensitivecompare(_:).md)
- [localizedCaseInsensitiveCompare(_:)](foundation/nsstring/localizedcaseinsensitivecompare(_:).md)
- [compare(_:)](foundation/nsstring/compare(_:).md)
- [localizedCompare(_:)](foundation/nsstring/localizedcompare(_:).md)
- [compare(_:options:)](foundation/nsstring/compare(_:options:).md)
- [compare(_:options:range:)](foundation/nsstring/compare(_:options:range:).md)
- [compare(_:options:range:locale:)](foundation/nsstring/compare(_:options:range:locale:).md)
- [localizedStandardCompare(_:)](foundation/nsstring/localizedstandardcompare(_:).md)
- [hasPrefix(_:)](foundation/nsstring/hasprefix(_:).md)
- [hasSuffix(_:)](foundation/nsstring/hassuffix(_:).md)
- [isEqual(to:)](foundation/nsstring/isequal(to:).md)
- [NSString.CompareOptions](foundation/nsstring/compareoptions.md)
- [NSString.EncodingConversionOptions](foundation/nsstring/encodingconversionoptions.md)
