Search code examples
iosobjective-ctextbufferhomekit

Adding custom text to UITextField buffer


Background: I have got a custom alert part of the HomeKit API. I'd like to allow the user to paste the code requested rather than inputting it manually.

enter image description here

Whenever there is text in the buffer it is possible to paste it by tapping on the textfield. How can I add custom text (from my App) to "this" buffer so the "paste" option appears?


Solution

  • You can populate the iPhone clipboard using below code. Put this code to a suitable place in your code.

    UIPasteboard *clipboard = [UIPasteboard generalPasteboard];  
    clipboard.string = @"<Assign Some value>";