2

I'm creating an app to save my copied items anytime I copy something on my iOS device.

Is there anyway I can create an event so that anytime I copy something from any app on my iOS device it saves it into my app?

I want it to fire anytime I copy text so that it pastes it to my apps textbox.

Kara
  • 6,115
  • 16
  • 50
  • 57
MattF
  • 65
  • 2
  • 11
  • 2
    Have you tried to write any code yet? – john_science Apr 06 '12 at 04:47
  • ive written some code to try and sent it to my database, but im struggling to create an event that will fire and send the copied text to the database as soon as i tap copy – MattF Apr 06 '12 at 04:59

3 Answers3

9
- (void)copy {

    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    pasteboard.string = @"String";
}


- (void)paste {

        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];  
        NSString *string = pasteboard.string; 
        NSLog(@"%@",string");
}

Refer this Link UIPasteBoard

Aravindhan
  • 15,608
  • 10
  • 56
  • 71
0

Take a look at the UIResponderStandardEditActions informal protocol:

https://developer.apple.com/library/ios/documentation/uikit/reference/UIResponderStandardEditActions_Protocol/UIResponderStandardEditActions.html

The key is to ensure that your view controller can become first responder and then implement the following methods:

- (void)copy:(id)sender;
- (void)paste:(id)sender;
-1
    UIPasteboard *pb = [UIPasteboard generalPasteboard];
    NSDictionary *CellData = [NSDictionary dictionaryWithDictionary:[ArrayName objectAtIndex:SelectedIndexPath.row]];
    NSString* strText = [(NSDictionary*)[(NSString*)[CellData objectForKey:@"Key"] JSONValue] objectForKey:@"english"];
    [pb setString:strText];
Shubham JAin
  • 593
  • 8
  • 15
  • 1
    Please put at least a sentence explaining what your code does and how it works. A block of nothing but code is rarely of much use without context. – Addison Nov 18 '16 at 07:34