<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSString/enumerateLines(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSString(im)enumerateLinesUsingBlock:"
  },
  "title" : "enumerateLines(_:)"
}
-->

# enumerateLines(_:)

Enumerates all the lines in the string.

```
func enumerateLines(_ block: @escaping (String, UnsafeMutablePointer<ObjCBool>) -> Void)
```

## Parameters

`block`

The block executed for the enumeration.

    The block takes two arguments:

- line: The current line of the string being enumerated. The line contains just the contents of the line, without the line terminators. See [`getLineStart(_:end:contentsEnd:for:)`](/documentation/Foundation/NSString/getLineStart(_:end:contentsEnd:for:)) for a discussion of line terminators.
- stop: A reference to a Boolean value that the block can use to stop the enumeration by setting `*stop = YES`; it should not touch `*stop` otherwise.

## Discussion

---

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)