0

I am using NSPasteboardWriting protocol for writing custom object on NSPasteboard. How to create UTI for custom object?

- (NSArray *)writableTypesForPasteboard:(NSPasteboard *)pasteboard {

static NSArray *writableTypes = nil;
if (!writableTypes) 
{ 
    writableTypes = [[NSArray alloc] initWithObjects:[FileSystemItem class], nil]; 
} 
NSLog(@"writable%@", writableTypes);
return writableTypes;

}

- (id)pasteboardPropertyListForType:(NSString *)type {
NSLog(@"type = %@", type);
return type;
}

FileSystemItem is my custom class. Are the above two methods are correct?

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Parag Bafna
  • 22,812
  • 8
  • 71
  • 144

1 Answers1

3

You don't "create" a UTI. You just use the same one everywhere you need it.

The standard pasteboard UTI format is:

com.mycompany.myapp.mypasteboardtype
spudwaffle
  • 2,905
  • 1
  • 22
  • 29
  • 2
    Worth noting: Everything there is a placeholder to be filled in, including the “com”. If your domain name is “example.org”, then your UTI should be “org.example.myapp.mypasteboardtype”. Also note that you should only do this for your own custom types, not existing types that you support. – Peter Hosey Sep 16 '11 at 20:22