Custom object on NSPasteboard

假装没事ソ 提交于 2020-01-17 10:23:38

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/7444545/custom-object-on-nspasteboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!