93

In my iPhone app, I have many ASCII arts which I need to insert into the database.

I am using the simulator and pasting the textpic in the textview to insert the ASCII art to database.

Here the clipboard of simulator once pastes the art properly but when I copy another art then too it pastes the previous art into textview.

How to solve this problem? Is there a work around for this or any better approach?

10 Answers 10

227

I was getting frustrated with copy and paste in the simulator and couldn't figure out what was going on.

Results were similar to what you describe: copy and paste would sometimes paste the same value as I had copied before, but not what I just copied to the clipboard.

I finally realized that the simulator has it's own clipboard, separate from the main OS X clipboard.

You use the touch-based copy and paste commands to paste into your application from the simulator clipboard.

You can use the standard OS X copy paste shortcuts (Command-X,C,V) to paste from the system clipboard into the simulator clipboard.

So to copy and paste from Chrome (for example), you select the text in Chrome, Command-C to copy. Then switch to the simulator, Command-V to paste into the simulator clipboard. Then in your application, you simulate a touch in the textfield to bring up the paste option, then simulate a touch to the paste button to paste the simulator clipboard contents into the app.

The menu options do the same thing as the keyboard shortcuts--copy/paste between the system clipboard and the simulator keyboard.

Now that I figured it out, I actually like it much better than if the simulator clipboard was automatically tied to the OS X clipboard.

6
  • 2
    I am always confused by the copy & paste between the simulator and MAC, your answer is awesome! thank you so much.
    – flypig
    Commented Nov 7, 2013 at 15:15
  • 3
    Thank you for the answer, and for pointing out what might be worst UI decision ever made. (Choose the "paste" option on the iOS Simulator pull-down...nothing happens...then go do "Paste" again? Though there is some conceptual sense behind it, it's just flat-out crazy to assume anyone could figure this out.) Commented Apr 14, 2014 at 22:12
  • Copying from the simulator seems to be broken in iOS 9. Tried all combinations of cmd-C and the 'copy' popup in simulator. Seems to be no way of 'grabbing' a text from the simulator.
    – bauerMusic
    Commented Oct 10, 2015 at 16:38
  • @bauerMusic It's not broken, but it will be copied to the clipboard of the simulator, not to the clipboard of your Mac. Commented Feb 4, 2016 at 16:08
  • @TimVermeulen The 'broken' part is the bridge between the two clipboards. It still goes one way (from Mac to Simulator) but not the other. Also, this has worked in previous versions. Hence, broken.
    – bauerMusic
    Commented Feb 7, 2016 at 10:59
36

From Xcode 9.0 or above:

  • Open simulator

  • Click on "Edit" from top menus

  • Enable -> "Automatically Sync Pasteboard"

  • If already enable then disable it and enable again.

  • Long press to paste your text i.e copied

Below Xcode 9.0

  1. Copy text from anywhere
  2. Paste on the simulator by command (command + v), it will show nothing
  3. Then press (command + shift + v)

it works for me

2
  • 2
    super helpful hint!
    – Robert
    Commented May 20, 2019 at 11:08
  • 2
    The ' If already enable then disable it and enable again.' was the key!
    – rsc
    Commented Jul 30, 2019 at 0:19
19
  • + C - Copies the contents of the iOS clipboard to OS X. This works for both text and images.
  • + + C - Copies the selected text (or whatever else responds to the copy: selector in your app) to the iOS clipboard. This one does not appear in the menu.
  • + + C - Copies a screenshot of the iOS app (without the simulator's chrome) to the OS X clipboard (Use + S to save it to a file on the Desktop instead).
  • + V - Copies the contents of the OS X clipboard over to iOS, but doesn't paste it. Again, this works for both text and images.
  • + + V - Pastes the OS X clipboard in the iOS app, but leaves the clipboard unchanged. This does not work with images.

Source: http://olemoritz.net/copypaste-in-the-ios-simulator.html

18

In Xcode 9 or above: 1. Active simulator 2. Check menu "Edit -> Automatically Sync Pasteboard" 3. Enjoy :)

0
8

I searched for an answer for this for some time. For Apple Silicon (M1) I eventually found a page where some users had tracked it down to an issue with iOS 14+. When I installed switched to a simulator iOS 13.7 as instructed (see link) pasting worked again. While this is clearly not what was going on with the original question (10 years ago!), I am pasting here in case someone else has this issue.

2

This is strange issue in my pc. I have macOs Sierra 10.xx++ installed in my mac. What i do is ,

  1. Copy the content from your mac using command + c or keyboard.

  2. Now press command + v in the particular place you want to paste the content.

  3. Now Paste in the simulator using command + shift + v

Working well. Confirmed answer.!

1

Check out the text property of the UITextView. Simply load your textpic into an NSString, and set that string to be the text property of the TextView.

http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextView_Class/Reference/UITextView.html%23//apple_ref/occ/instp/UITextView/text

1
  • No problem, anytime, I'm just glad you got your answer. Commented Jan 6, 2011 at 12:00
0

You can copy the content from mac using ⌘ + ⇧ + C and paste in browser url using ⌘ + V .

It's working for me.

0

As a last step try to restart Xcode and iOS simulator
Menu -> Hardware -> Restart

-5

Got the solution:

From iPhone Simulator menu.

Third option: Restore Content and Settings.

You will lose all the apps installed in the simulator along with the settings.

Got this working for me.

1
  • 3
    This is not an answer to the actual question.
    – smyk
    Commented Aug 18, 2016 at 18:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.