title: NSView Drag Operation Error
body: <p>I'm coding in Cocoa, on OS X.</p>
  
  <p>I'm trying to receive a file that is dragged and dropped onto my NSView subclass - which I can do; and <strong>get its contents and filename and display them</strong> - which I can do for any type of file <strong>first time</strong>, but <strong>on the second time, when I try and drag another file on, I can only set the title <code>setTitle:</code>, but not the main body text <code>setText:</code></strong></p>
  
  <p><strong>The errors I am getting are:</strong> </p>
  
  <blockquote>
    <p>Canceling drag because exception 'NSInternalInconsistencyException' (reason 'Invalid parameter not satisfying: aString != nil') was raised during a dragging session</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>Assertion failure in -[NSTextFieldCell _objectValue:forString:errorDescription:], /SourceCache/AppKit/AppKit-1187/AppKit.subproj/NSCell.m:1532</p>
  </blockquote>
  
  <p><strong>My code (sorry, it's quite long!):</strong></p>
  
  <pre><code>- (BOOL)performDragOperation:(id&lt;NSDraggingInfo&gt;)sender {
  NSPasteboard *pboard;
  NSDragOperation sourceDragMask;
  
  sourceDragMask = [sender draggingSourceOperationMask];
  pboard = [sender draggingPasteboard];
  
  if ([[pboard types] containsObject:NSFilenamesPboardType]) {
  
      NSURL *file = [NSURL URLFromPasteboard:pboard];
      //NSData *data = [NSData dataWithContentsOfURL:file];
  
      NSError *error;
      NSStringEncoding encoding;
      NSString *contentString = [[NSString alloc] initWithContentsOfURL:file usedEncoding:&amp;encoding error:&amp;error];
  
      NSLog(@"Error: %@",error);
  
      NSString *last = [[file path] lastPathComponent];
      NSArray *parts = [last componentsSeparatedByString:@"."];
      NSString *filename = [parts objectAtIndex:0];
      NSString *fileType = [parts objectAtIndex:1];
  
      NSLog(@"FILETYPE: %@", fileType);
  
      if ([fileType isEqualToString:@"txt"] || [fileType isEqualToString:@"md"]) {
          [self setTitle:filename];
  
          if (self.textViewString == (id)[NSNull null] || self.textViewString.length == 0) {
              [self setText:contentString];
          } else {
              BOOL whatToDo = (NSRunCriticalAlertPanel(@"What do you want to do?", nil, @"Append", @"Replace", nil) == NSAlertDefaultReturn);
  
              if (whatToDo) {
                  //Append
                  [self setText:[NSString stringWithFormat:@"%@\n%@",self.textViewString,contentString]];
              } else {
                  //Replace
                  [self setText:contentString];
              }
          }
          return YES;
      } else {
          return NO;
      }
  } else if ([[pboard types] containsObject:NSPasteboardTypeString]) {
      NSString *draggedString = [pboard stringForType:NSPasteboardTypeString];
  
      if (self.textViewString == (id)[NSNull null] || self.textViewString.length == 0) {
          [self setText:draggedString];
      } else {
          [self setText:[NSString stringWithFormat:@"%@\n%@",self.textViewString,draggedString]];
      }
      return YES;
  }
  else {
      return NO;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Thanks in advance! :)</p>