views:

29

answers:

1

Hi, I'm trying to to paste something to the generalPasteboard but I keep getting some warnings because I'm using 10.6 coding in my 10.5 app. Can someone please fix this code to make it compile for 10.5 or earlier versions of OS X. Thanks

NSString *areacode = @"774";

    NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
    [pasteboard clearContents];
    NSArray *copiedObjects = [NSArray arrayWithObject:[NSString stringWithFormat:@"%@%@", areacode, phone]];
    [pasteboard writeObjects:copiedObjects];

Right now I'm getting this warning message "NSPasteboard may not respond to -clearContents and writeObjects"

+1  A: 

The pre-Snow-Leopard way to interact with a pasteboard was to declare the types you're going to put on it, then (optionally) put data on the pasteboard for those types. If you skip the latter step, then, as the current owner of the pasteboard, the pasteboard will call you back when somebody requests data for a type you didn't already provide data for.

See the documentation for further info.

Peter Hosey