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

  • Home
  • SEARCH
  • 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 797523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:49:11+00:00 2026-05-14T22:49:11+00:00

I’m trying to paste text right into where the cursor currently is. I have

  • 0

I’m trying to paste text right into where the cursor currently is. I have been trying to do what it says at:
– http://dev.ragfield.com/2009/09/insert-text-at-current-cursor-location.html

The main deal is that I can’t just go textbox1.text (etc) because the textfield is in the middle of a custom cell. I want to just have some text added to where the cursor is (when I press a custom key on a keyboard).

-I just want to paste a decimal into the textbox…

The error I get is:

2010-05-15 22:37:20.797 PageControl[37962:207] * -[MyDetailController paste:]: unrecognized selector sent to instance 0x1973d10
2010-05-15 22:37:20.797 PageControl[37962:207] *
Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘*** -[MyDetailController paste:]: unrecognized selector sent to instance 0x1973d10’

Note: I have access to the textfield tag (if that helps?)

I’m a little past the beginner stage in objective-c, but still not great. My code is currently below, and at https://gist.github.com/d634329e5ddf52945989

Thanks all.


MyDetailController.h

    @interface MyDetailController : UITableViewController <UITextFieldDelegate,UINavigationControllerDelegate>
{

//...(lots in here)

}


@end


@interface UIResponder(UIResponderInsertTextAdditions)
- (void) insertText: (NSString*) text;
@end

MyDetailController.m

@implementation MyDetailController


//.... (lots in here)



- (void)addDecimal:(NSNotification *)notification {
    // Apend the Decimal to the TextField.
    //savedAmount.text = [savedAmount.text stringByAppendingString:@"."];

    NSLog(@"Decimal Pressed");
    NSLog(@"tagClicked: %d",tagClicked);
    switch (tagClicked) {
        case 7:

            //savedAmount.text = [savedAmount.text stringByAppendingString:@"."];
            break;
        case 8:
            //goalAmount.text = [goalAmount.text stringByAppendingString:@"."];
            break;
        case 9:
            //incrementAmount.text = [incrementAmount.text stringByAppendingString:@"."];
            break;      
        case 10:
            //incrementAmount.text = [incrementAmount.text stringByAppendingString:@"."];
        break;  
    }

    [self insertText:@"."];
}

-(void)textFieldDidBeginEditing:(UITextField *)textfield{

    //UITextField *theCell = (UITextField *)sender;
    tagClicked = textfield.tag;
    NSLog(@"textfield changed. tagClicked: %d",tagClicked);



}

@end

    @implementation UIResponder(UIResponderInsertTextAdditions)

    - (void) insertText: (NSString*) text
    {
        // Get a refererence to the system pasteboard because that's
        // the only one @selector(paste:) will use.
        UIPasteboard* generalPasteboard = [UIPasteboard generalPasteboard];

        // Save a copy of the system pasteboard's items
        // so we can restore them later.
        NSArray* items = [generalPasteboard.items copy];

        // Set the contents of the system pasteboard
        // to the text we wish to insert.
        generalPasteboard.string = text;

        // Tell this responder to paste the contents of the
        // system pasteboard at the current cursor location.
        [self paste: self];

        // Restore the system pasteboard to its original items.
        generalPasteboard.items = items;

        // Free the items array we copied earlier.
        [items release];
    }

    @end
  • 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-14T22:49:12+00:00Added an answer on May 14, 2026 at 10:49 pm

    UIViewController is a UIResponder… but it’s not the UIResopnder that should receive the insertText: message. You want to call insertText: on the UITextField itself. If you take a look at UIResponder.h you’ll see the following comment near the paste: method

    // these methods are not implemented in NSObject

    Meaning that it’s not necessarily safe to call them on just any UIResponder. They can only safely be called on subclasses such as UITextField and UITextView which actually implement them. This was a really strange design decision on Apple’s part.

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

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put

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.