forked from xamarin/Essentials
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Clipboard.ios.cs
37 lines (30 loc) · 1.01 KB
/
Clipboard.ios.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Threading.Tasks;
using Foundation;
using UIKit;
namespace Xamarin.Essentials
{
public static partial class Clipboard
{
static Task PlatformSetTextAsync(string text)
{
UIPasteboard.General.String = text;
return Task.CompletedTask;
}
static NSObject observer;
static bool PlatformHasText
=> UIPasteboard.General.HasStrings;
static Task<string> PlatformGetTextAsync()
=> Task.FromResult(UIPasteboard.General.String);
static void StartClipboardListeners()
{
observer = NSNotificationCenter.DefaultCenter.AddObserver(
UIPasteboard.ChangedNotification,
ClipboardChangedObserver);
}
static void StopClipboardListeners()
=> NSNotificationCenter.DefaultCenter.RemoveObserver(observer);
static void ClipboardChangedObserver(NSNotification notification)
=> ClipboardChangedInternal();
}
}