Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6924703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:41:46+00:00 2026-05-27T10:41:46+00:00

UITextField and UITextView both adopt the UITextInput protocol. UITextView’s selectedRange property returns NSRange, where

  • 0

UITextField and UITextView both adopt the UITextInput protocol. UITextView’s selectedRange property returns NSRange, where UITextField doesn’t have any selection properties/methods. I’d like to use one routine to manage insertion in either UITextField or UITextView.

So I do the following:

    id<UITextInput> textInput = nil;

    if ([self.aTextView isFirstResponder]) {
        textInput = self.aTextView;
    } else if ([self.aTextField isFirstResponder]) {
        textInput = self.aTextField;
    }

    if (textInput != nil) {
        UITextRange * selectedRange = textInput.selectedTextRange;
        // ...
    }

Only to promptly crash with ‘unrecognized selector sent to instance’ on the selectedTextRange property.

What am I doing wrong?

[EDIT: seems to work in iOS 5, but crashes on device in iOS 4. Is this a change in iOS 5? The docs say the protocol is 3.2+.]

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:41:47+00:00Added an answer on May 27, 2026 at 10:41 am

    I verified in my own app that UITextView and UITextField both crash with -[UITextView selectedTextRange]: unrecognized selector in the iOS 4 simulator but not the iOS 5 simulator.

    The answer to this question suggests that the conformance to UITextInput is a new thing in iOS 5: Can I select a specific block of text in a UITextField? . So it appears that the protocol itself is iOS 3.2, but UITextView/Field didn’t make use of that protocol before iOS 5.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario: I have two UITableViewCells containing a UITextField property and UITextView property respectively. Obviously
I would like to have a UITextField or UITextView in where as I do
I have a UITextView and 2 UITextField set up. UITextView resigns first responder status
Facing some weird moment of my career. I have some uitextfield's and one uitextview
I get stuck with my cell selection. I have custom cell with UITextView object
I have a UITextField that I put into a UITableViewCell that I put into
I have a UITextField but when it overflows I want it to scroll not
I created a UITextField in code, now I have now idea how to define
I have a UITextField in my app that accepts decimal amounts for prices (i.e.,
I have an UITextField and I would like that for every tap on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.