<!--
{
  "availability" : [
    "iOS: 5.0.0 - 9.0.0",
    "iPadOS: 5.0.0 - 9.0.0",
    "macCatalyst: 13.1.0 - 13.1.0"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIAlertView/textField(at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIAlertView(im)textFieldAtIndex:"
  },
  "title" : "textField(at:)"
}
-->

# textField(at:)

Returns the text field at the given index

```
func textField(at textFieldIndex: Int) -> UITextField?
```

## Parameters

`textFieldIndex`

The index of the text field. The text field indices start at `0`.

## Return Value

The text field specified by index `textFieldIndex`.

## Discussion

The number of text fields present in an alert is dependent on the style of the alert.

|Alert Style                                                                         |Text Fields                                                         |
|------------------------------------------------------------------------------------|--------------------------------------------------------------------|
|``doc://com.apple.uikit/documentation/UIKit/UIAlertViewStyle/default``              |No user-editable text fields.                                       |
|``doc://com.apple.uikit/documentation/UIKit/UIAlertViewStyle/secureTextInput``      |A single text field at index `0`.                                   |
|``doc://com.apple.uikit/documentation/UIKit/UIAlertViewStyle/plainTextInput``       |A single text field at index `0`.                                   |
|``doc://com.apple.uikit/documentation/UIKit/UIAlertViewStyle/loginAndPasswordInput``|The login field is at index `0`. The password field is at index `1`.|

If your application attempts to retrieve a text field with an index that is out of bounds, the alert raises an <doc://com.apple.documentation/documentation/Foundation/NSExceptionName/rangeException>.

---

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)