# Fill PDF form fields programmatically on iOS

Nutrient iOS SDK fully supports the AcroForm standard, and forms can be viewed and filled inside the [`PDFViewController`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller).

Forms are an optional component that can be licensed. If not licensed, forms will simply be invisible. Forms can also be manually switched off by setting the [`formsEnabled`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document/areformsenabled) property of a [`Document`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document) to `false`.

The Nutrient Catalog example in the examples directory of the framework download contains a Programmatic Form Filling example that demonstrates how objects can be queried and modified:

### SWIFT

```swift

// Model editing needs to happen on the main thread.
let annotations = document.annotationsForPage(at: 0, type:.widget)
for annotation in annotations {
    switch annotation {
    case let textFieldFormElement as TextFieldFormElement:
        guard let fieldName = textFieldFormElement.fieldName else { return }
        textFieldFormElement.contents = String(format: "Test %@", arguments: [fieldName])
    case let buttonFormElement as ButtonFormElement:
        buttonFormElement.toggleButtonSelectionState()
    default:
        break
    }
}

```

### OBJECTIVE-C

```objc

// Model editing needs to happen on the main thread.
NSArray *annotations = [document annotationsForPageAtIndex:0 type:PSPDFAnnotationTypeWidget];
for (PSPDFFormElement *formElement in annotations) {
    if ([formElement isKindOfClass:PSPDFTextFieldFormElement.class]) {
        formElement.contents = [NSString stringWithFormat:@"Test %@", formElement.fieldName];
    } else if ([formElement isKindOfClass:PSPDFButtonFormElement.class]) {
        [(PSPDFButtonFormElement *)formElement toggleButtonSelectionState];
    }
}

```
---

## Related pages

- [Attach a file to a PDF form field on iOS](/guides/ios/forms/fill-form-fields/attach-a-file.md)
- [Add or edit images in PDF form fields on iOS](/guides/ios/forms/fill-form-fields/image-picker.md)
- [Detect user input in PDF form fields on iOS](/guides/ios/forms/fill-form-fields/detect-user-input.md)
- [Form field support in our iOS viewer](/guides/ios/forms/fill-form-fields/using-the-ui.md)
- [Undo and redo for PDF forms on iOS](/guides/ios/forms/fill-form-fields/undo-and-redo.md)

