tags:

views:

40

answers:

2

I am using the following code to perform drag operation on NSTextView object.

- (BOOL)performDragOperation:(id )sender
{
    NSPasteboard *pboard = [sender draggingPasteboard];
    if ( [[pboard types] containsObject:NSURLPboardType] ) 
    {
        NSURL *fileURL = [NSURL URLFromPasteboard:pboard];
        if ([[fileURL path] hasSuffix:@"plist"]) 
        {
            NSString *code = [NSString stringWithContentsOfURL:fileURL encoding:NSUTF8StringEncoding error:NULL];
            int cnt = [[self string] length];
            if (cnt) [self setSelectedRange:NSMakeRange(0, cnt)];
            [self insertText:code];
            return YES;
        }
    }
    return NO;
}

I have declared this method in the .h file as well.

But after running the code it showing following warnings.

warning: 'AppConroller' may not respond to '-string' (Messages without a matching method signature will be assumed to return 'id' and accept'...' as arguments.)

warning: 'AppConroller' may not respond to '-setSelectedRange:'

warning: 'AppConroller' may not respond to '-insertText:'

A: 

You're sending self (the AppController) messages it doesn't support. I think you mean to have [sender string], [sender setSelectedRange:], and [sender insertText:].

refulgentis
Hi. using above methods, the warnings has gone but when i m dragging a file on textview it still showing file path. i want it to show the file contents
Shakti
A: 

Is it possible it's just a typo? All your warnings refer to "AppConroller", but I bet the class is actually named "AppController".

Jay Goodman Tamboli