Re: drags from iTunes in an NSView just like iWeb [Solved]

  • hi guys,
      Finally i achive what i want and i thankfull to all of you who replied for my problem.
      specially Fritz Anderson , David Dunham and Jim Puls.
      Actually i missed some methods to overrides, but now i wrote that methods and reached to solution.
      My final code snippest is as follows,

    - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
    {
    return NSDragOperationGeneric;
    }

    - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
    {
    return NSDragOperationGeneric;
    }

    - (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
    {
        return YES;
    }
    - (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];
        NSArray *urlArray = [paste propertyListForType:NSFilenamesPboardType];
        NSString *data = [[NSString alloc] initWithString:[urlArray objectAtIndex:0]];
        NSLog([data description]);
        if (nil == carriedData)
        {
            NSRunAlertPanel(@"Paste Error", @"Sorry, but the past operation failed", nil, nil, nil);
            return NO;
        }
        else
        {
      if([musicFileType containsObject:[data pathExtension]])
      {
      [self createMusic:data];
      }
      else if([movieFileType containsObject:[data pathExtension]])
      {
      [self createMovie:data];
      }
      else if([imageFileType containsObject:[data pathExtension]])
      {
      [self createImage:data];
      }
      else if([docFileType containsObject:[data pathExtension]])
      {
      [self createDoc:data];
      }
      else
      {
      NSRunAlertPanel(@"UnSupported Files", @"Sorry, but the past operation failed due to unsupported files ", nil, nil, nil);
      }
    }
        return YES;
    }

    There are again some methodes which can be  use depends on indivisual requirement and these are,
    - (void)draggingExited:(id <NSDraggingInfo>)sender

    - (void)draggingEnded:(id <NSDraggingInfo>)sender

    - (void)concludeDragOperation:(id <NSDraggingInfo>)sender

    I again thanks to all of you.

    --
    ______________________________________________
    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!
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today