<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NaturalLanguage",
  "identifier" : "/documentation/NaturalLanguage/NLEmbedding/neighborsForString:maximumCount:maximumDistance:distanceType:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Natural Language"
    ],
    "preciseIdentifier" : "c:objc(cs)NLEmbedding(im)neighborsForString:maximumCount:maximumDistance:distanceType:"
  },
  "title" : "neighborsForString:maximumCount:maximumDistance:distanceType:"
}
-->

# neighborsForString:maximumCount:maximumDistance:distanceType:

Retrieves a limited number of strings, within a radius of a string, in the vocabulary.

```
- (NSArray<NSString *> *) neighborsForString:(NSString *) string maximumCount:(NSUInteger) maxCount maximumDistance:(NLDistance) maxDistance distanceType:(NLDistanceType) distanceType;
```

## Parameters

`string`

A string in the embedding vocabulary.

`maxCount`

The largest number of neighboring strings that the method can return in an array.

`maxDistance`

The largest distance a neighbor can be from `string`.

`distanceType`

A means of calculating distance that determines which formula the method uses to evaluate a neighbor’s distance from `string`.

## Return Value

An array of neighboring strings.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)