Re: Quastion about types in a NSPasteBoard
Re: Quastion about types in a NSPasteBoard
- Subject: Re: Quastion about types in a NSPasteBoard
- From: Gustavo Pizano <email@hidden>
- Date: Thu, 10 Dec 2009 12:26:08 +0100
Hello Graham.
In fact the AbstractFactory has nothing to do with the NSPasteBoard. Im reading the NSPasteBoard in the NSViewController after it's view has recevied the performDropOperation:
so this is what Im doing:
NSPasteBoard pb = [sender draggingPasteboard]
NSArray * types = [pb types];
if([types containsObject:DefaultHorizontal]){
...
...
}
else if ( .... ){
}
else if (....){
}
So depending on what I have dragged, Im asking the AbstractFactory to create an specific object. In the AbstractFactory Im not touching pb. ...
I jsut wanted to see from where is it coming, so I could just do something like..
CustomObject a = [<AbstractFactory> createObjectWithName:[[types objectAtIndex:1] description]];
or something like that instead of doing all those if-else clauses.
Gustavo
On Dec 10, 2009, at 11:39 AM, Graham Cox wrote:
>
> On 10/12/2009, at 9:26 PM, Gustavo Pizano wrote:
>
>> I have implemented a drag and drop, and I just wanted to check what I had in the NSPasteBoard on drop...
>>
>> I checked the types from the NSPasteBoard, and the type I declared when dragging is in the second place of the returning array. in first place it's. something like:
>>
>> dyn.ah62d4rv4gu8zuz4xkvw0q2pzrv4fq3pwsvy0g2pqnrka
>>
>> can somebody explain me what's that? can I safely take the 2 type in the array so I can pass it to my AbstractFactory and avoid a bunch of code lines.?
>
>
> Who can say, without knowing how you've implemented your AbstractFactory?
>
> I'd say what you should do is follow the recommended approach for receiving data from a pasteboard, and request the types you're interested in in the order you want them. That way your code will be unaware of any private data the system has added to pasteboard and so you don't need to care about it.
>
> http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/PasteboardGuide106/Introduction/Introduction.html
>
> --Graham
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden