开发者

registerForDraggedTypes with custom file formats

开发者 https://www.devze.com 2022-12-25 23:19 出处:网络
Developer Documentations doesn\'t provides fully describe of registerForDraggedTypes method. For example, i want that my app all开发者_开发问答ow access only \"*.abc\" files. How can i do this?If you\

Developer Documentations doesn't provides fully describe of registerForDraggedTypes method. For example, i want that my app all开发者_开发问答ow access only "*.abc" files. How can i do this?


If you'd like to have files dragged onto your view, your should register for the NSFilenamesPboardType type. If you want accept only certain filenames, you can do that in your implementation of performDragOperation:. Something like:

- (BOOL)performDragOperation:(id < NSDraggingInfo >)sender {
    NSArray *draggedFilenames = [[sender draggingPasteboard] propertyListForType:NSFilenamesPboardType];
    if ([[[draggedFilenames objectAtIndex:0] pathExtension] isEqual:@"abc"])
        return YES;
    else
        return NO;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消