<!--
{
  "availability" : [
    "iOS: 2.0.0 - 13.0.0",
    "iPadOS: 2.0.0 - 13.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.0.0 - 10.15.0",
    "tvOS: 9.0.0 - 13.0.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 2.0.0 - 6.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Scanner/scanString(_:into:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSScanner(im)scanString:intoString:"
  },
  "title" : "scanString(_:into:)"
}
-->

# scanString(_:into:)

Scans a given string, returning an equivalent string object by reference if a match is found.

```
func scanString(_ string: String, into result: AutoreleasingUnsafeMutablePointer<NSString?>?) -> Bool
```

## Parameters

`string`

The string for which to scan at the current scan location.

`result`

Upon return, if the receiver contains a string equivalent to `string` at the current scan location, contains a string equivalent to `string`.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if `string` matches the characters at the scan location, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

If `string` is present at the current scan location, then the current scan location is advanced to after the string; otherwise the scan location does not change.

Invoke this method with `NULL` as `stringValue` to simply scan past a given string.

---

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)