• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Drag From iTunes in NSView just like iWeb did
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drag From iTunes in NSView just like iWeb did


  • Subject: Re: Drag From iTunes in NSView just like iWeb did
  • From: "Nishant Yede" <email@hidden>
  • Date: Fri, 29 Sep 2006 13:01:21 +0530

hi
  Thanks for your comments and i tried all your suggestions and now i am able to drag all kind of files from
  finder but not from "iTune" and from "mediaBrowser" which i really want.

  I am egarly waiting for your reply.

> I can offer some comments, though I don't know how far they may
> bring  you toward your goal. Much of the work you will have to do
> yourself.
>
> On Sep 28, 2006, at 2:20 AM, Nishant Yede wrote:
>
> >   in init method i wrote
> >     [self registerForDraggedTypes:[NSArray
> > arrayWithObject:NSFilenamesPboardType]];
> >
> > - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
> > {
> >     NSPasteboard *paste = [sender draggingPasteboard];
> >     NSArray *types = [NSArray  arrayWithObjects:NSFilenamesPboardType,nil];
> >     NSString *desiredType = [paste availableTypeFromArray:types];
> >     NSData *carriedData = [paste dataForType:desiredType];
>
> The only possible values for desiredType are NSFilenamesPboardType
> (if  it's present) or nil (if it's not). What are you doing about
> the  possibility that desiredType is nil?
>
> >     NSArray *urlArray = [paste propertyListForType:NSURLPboardType];
>
> Elsewhere you expressed interest in the list-of-filenames
> pasteboard  type (which is an array, a property-list type). Now you
> are pulling  something else, a single URL, out of the pasteboard
> (assuming there is  one), and casting it to an array. Why?
>
> Aside from the fact that urlArray would not be an array, what are
> you  doing about its possibly being nil?
>
> >     NSString *data = [[NSString alloc] initWithString:[urlArray
> > objectAtIndex:0]];
>
> If urlArray is a URL, it doesn't recognize objectAtIndex:, a
> diagnostic will be printed to that effect, and execution of this
> method will be abandoned here. If it's nil, it will be passed with
> the  initWithString: message, which is documented not to tolerate a
> nil  parameter, so this is a crasher, or causes an exception, which
> again  would abandon the execution of this method.
>
> "data" is a name an experienced Cocoa programmer would not choose
> for  a string. Strings and data are concepts one would be at pains
> to keep  separate.
>
> Is there some reason you want to allocate (but never release) a new
>   NSString with content identical to the NSString you assume you'd
> get  from objectAtIndex: ?
>
> And, if you aren't yet sure what pasteboard type you should look
> for,  why has it not helped you to put a breakpoint in this
> function and  type "po [paste types]" in the GDB console? I'll
> admit to having been  baffled at pasteboards more than once; I'll
> probably be baffled the  next time. But stepping, interrogating the
> pasteboard, and examining  the method results always pulled me
> through.
>
> >     if (nil == carriedData)
> >     {
> >         NSRunAlertPanel(@"Paste Error", @"Sorry, but the past
> > operation failed", nil, nil, nil);
>
> Even if you're the only one to see them, it's worth the very small
> trouble to make your error messages informative. For instance,
> @"Could  not get data for expected pasteboard type '%@'", nil, nil,
> nil,  desiredType. This is still very rude to a user, but you might
> find it  useful.
>
> >         return NO;
> >     }
> >     else
> >     {
> > 		data = [data substringFromIndex:16];
>
> Eh? What is it about "data" that leads you to expect that you can
> drop  the first 16 characters and get something useful? I can't
> think of a  class of URLs for which that would be true.
>
> > 		NSLog(data);
> > 		if([musicFileType containsObject:[data pathExtension]])
> ...
> >     return YES;
> > }
> >    Please check this code and reply what i did wrong in this.
>
> Sigh.
>
> Life is hard, but surely your time would be better spent in reading
>   the documentation, thus acquiring the skills you need to see for
> yourself what you did wrong? Or in stepping through you code with a
>   debugger, thus giving you the information you need to understand
> what  you did wrong?
>
> 	-- F

>


--
______________________________________________
IndiaInfo Mail - the free e-mail service with a difference! www.indiainfo.com
Check out our value-added Premium features, such as an extra 20MB for mail storage, POP3, e-mail forwarding, and ads-free mailboxes!
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Drag From iTunes in NSView just like iWeb did
      • From: Jim Puls <email@hidden>
  • Prev by Date: Custom binding problem...can't figure out how to trigger a notification on set
  • Next by Date: Re: Pixel Size
  • Previous by thread: Re: Drag From iTunes in NSView just like iWeb did
  • Next by thread: Re: Drag From iTunes in NSView just like iWeb did
  • Index(es):
    • Date
    • Thread