<!--
{
  "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/enumerateNeighborsForString:maximumCount:distanceType:usingBlock:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Natural Language"
    ],
    "preciseIdentifier" : "c:objc(cs)NLEmbedding(im)enumerateNeighborsForString:maximumCount:distanceType:usingBlock:"
  },
  "title" : "enumerateNeighborsForString:maximumCount:distanceType:usingBlock:"
}
-->

# enumerateNeighborsForString:maximumCount:distanceType:usingBlock:

Passes the nearest strings of a string in the vocabulary to a block.

```
- (void) enumerateNeighborsForString:(NSString *) string maximumCount:(NSUInteger) maxCount distanceType:(NLDistanceType) distanceType usingBlock:(void (^)(NSString *neighbor, NLDistance distance, BOOL *stop)) block;
```

## Parameters

`string`

A location in the vocabulary space.

`maxCount`

The largest number of times the method calls `block`.

`distanceType`

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

`block`

A block with the following parameters:

- `neighbor`: A neighboring string.
- `distance`: The distance from `string` to the neighboring string.
- `stop`: A Boolean that indicates whether to stop enumerating neighbors.

---

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)