Parag Bafna
Parag Bafna

Reputation: 22930

Custom object on NSPasteboard

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?

Upvotes: 0

Views: 1485

Answers (1)

spudwaffle
spudwaffle

Reputation: 2925

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

Upvotes: 3

Related Questions