On 10/12/2009, at 10:26 PM, Gustavo Pizano wrote:

> 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:

Yes, but my point was that AbstractFactory is your code, and yours alone, so 
whether it will directly accept objects returned from the pasteboard's methods 
is known only to you, so it's not a question anybody else can answer.


>       NSArray * types = [pb types];
>       if([types containsObject:DefaultHorizontal]){


You shouldn't be looking for what types the pasteboard has like this. You 
should be asking it whether it has the types you want, in the order you want 
them,  using -availableTypeFromArray:

Given those types something will have to map those to the classes your abstract 
factory makes. A bunch of if...else clauses is one way, but there smarter ways, 
like having a dictionary that maps type -> class.

e.g.

NSString* myType = [pb availableTypeFromArray:[NSArray 
arrayWithObjects:@"first_choice", @"second_choice", nil]];
Class     theClass = [classMapDictionary objectForKey:myType];

if( theClass )
{
    id object = [[theClass alloc] init];
}


If you are targeting 10.6 or later, the pasteboard supports multiple objects 
and there are new APIs to get them. But for 10.5 and earlier, the pasteboard 
can only hold one object, albeit in a different number of representations. If 
the data is private to your app, you can get around that by passing an array of 
objects in some fashion, but for data passed between apps, you're pretty much 
stuck with the standard types unless yours and the other app agree on some 
common protocol.

But to get back to your original post - anything you see on the pasteboard you 
don't recognise is none of your business - it's probably data private to the 
app where the drag started.

--Graham


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to