File: clipboard_ios.m

package info (click to toggle)
golang-golang-x-clipboard 0.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 552 kB
  • sloc: ansic: 264; xml: 19; makefile: 12; sh: 3
file content (20 lines) | stat: -rw-r--r-- 599 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright 2021 The golang.design Initiative Authors.
// All rights reserved. Use of this source code is governed
// by a MIT license that can be found in the LICENSE file.
//
// Written by Changkun Ou <changkun.de>

//go:build ios

#import <UIKit/UIKit.h>
#import <MobileCoreServices/MobileCoreServices.h>

void clipboard_write_string(char *s) {
    NSString *value = [NSString stringWithUTF8String:s];
    [[UIPasteboard generalPasteboard] setString:value];
}

char *clipboard_read_string() {
    NSString *str = [[UIPasteboard generalPasteboard] string];
    return (char *)[str UTF8String];
}