iPhone generalPasteboard loses contents if application is closed by an -openURL: call

Posted by Kojiro on Stack Overflow See other posts from Stack Overflow or by Kojiro
Published on 2010-04-14T02:31:46Z Indexed on 2010/04/14 2:43 UTC
Read the original article Hit count: 463

I have a method, that puts something on the pasteboard. This method is called one of two ways, one, as an IBAction from a button, the other from another method which afterwards closes the application by doing:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:"]];

The problem arises only when the application is not closed using the home button, but is closed using the line above. When that happens, the pasteboard contents are lost. I assume this problem has something to do with the object being cleaned up improperly when it closes this way, but have no idea why it is doing that. I have even tried to intentionally leak the object that gets put on the pasteboard, but it still gets lost on the way out.

Here is the method:

- (IBAction) copyLink {
    NSString *stringForPasteboard = @"here is the string";
    [[UIPasteboard generalPasteboard] setURL:stringForPasteboard];
    [stringForPasteboard release];
}

© Stack Overflow or respective owner

Related posts about uipasteboard

Related posts about generalpasteboard