Skip to content

gologo13/GLPasteboardMonitor

Repository files navigation

GLPasteboardMonitor

GLPasteboardMonitor detects a change of the general pasteboard of the UIPasteboard.

Usage

initialization and how to start and stop monitoring.

#import “GLPasteboardMonitor.h”

GLPasteboardMonitor *monitor = [GLPasteboardMonitor alloc] initWithDelegate:delegate];

// start monitoring
[monitor run];

// stop monitoring
[monitor stop];

To receive a change of the general pasteboard, implement these delegate methods.

- (void)pasteboardMonitor:(GLPasteboardMonitor *)Monitor didChangeString:(NSString *)newCopiedString;

- (void)pasteboardMonitor:(GLPasteboardMonitor *)Monitor didChangeImage:(UIImage *)newCopiedImage;

Finally, to keep monitoring pasteboard, you must implement the task competion in your app delegate.

@interface GLAppDelegate () <GLPasteboardMonitorDelegate>

@property (nonatomic, assign) UIBackgroundTaskIdentifier backgroundTask;

@end


- (void)applicationDidEnterBackground:(UIApplication *)application
{
    self.backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
        [application endBackgroundTask:self.backgroundTask];
        self.backgroundTask = UIBackgroundTaskInvalid;
    }];
}

Requirement

GLPasteboardMonitor must be built with ARC enabled.

License

GLPasteboardMonitor is available under the MIT license.

About

GLPasteboardMonitor monitors a change of the general pasteboard.

Resources

License

Stars

Watchers

Forks

Packages

No packages published