<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSAttributedString/initWithContentsOfMarkdownFileAtURL:options:baseURL:error:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAttributedString(im)initWithContentsOfMarkdownFileAtURL:options:baseURL:error:"
  },
  "title" : "initWithContentsOfMarkdownFileAtURL:options:baseURL:error:"
}
-->

# initWithContentsOfMarkdownFileAtURL:options:baseURL:error:

Creates an attributed string from the contents of a specified URL that contains Markdown-formatted data using the provided options.

```
- (instancetype) initWithContentsOfMarkdownFileAtURL:(NSURL *) markdownFile options:(NSAttributedStringMarkdownParsingOptions *) options baseURL:(NSURL *) baseURL error:(NSError **) error;
```

## Parameters

`markdownFile`

The URL to load Markdown-formatted data from.

`options`

Options that affect how the initializer interprets formatting in the Markdown string. This parameter defaults to no options.

`baseURL`

The base URL to use when resolving Markdown URLs. The initializer treats URLs as being relative to this URL. If this value is `nil`, the initializer doesn’t resolve URLs. The default is `nil`.

`error`

On input, a pointer to an error object. On return, if an error occurs, this pointer contains an actual error object with the error information. You may specify `nil` for this parameter if you don’t want the error information.

## Return Value

An attributed string with the parsed Markdown text and styling, or `nil` if parsing the data fails.

---

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)