关于NSoutlineView和WriteItem | 拖动和拖放问题(Regarding NS

2019-11-04 14:45发布

为了处理拖放正下降已经做以下,

-(void)InitMyOutlineView{
 - - - - -  - - - - - - - -  -- - - - - - - -  -
 - - - - - - - - - - - - - -- -- - - - - - - - - 
[pMyOutlineView registerForDraggedTypes:
     [NSArray arrayWithObject:NSStringPboardType]];

/* I tried both Yes and No */   
[pMyOutlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:NO];
- - - -  -- - - - - - -- - - - - - - -- - - - - - 
- -- -- - - - - -- - - - - - - - - - -  - -- - - - 
}

如下面的WriteItem方法,

- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard{
    [self log:@"write Items"];
    NSString *pStr = [NSString stringWithFormat:@"this is the temp string "];
       [pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:self];
       [pboard setString:pStr forType:NSStringPboardType];
       [self log:@"returning YES"];
       return YES;
}

现在,我期待控制会来AcceptDrop方法,但经过一段时间点没有命中,在那里和日志/ GDB得到以下日志

2011-02-04 16:21:25.435 MyApp[2006:a0f] write Items
2011-02-04 16:21:25.437 MyApp[2006:a0f] returning YES
2011-02-04 16:21:25.439 MyApp[2006:a0f] *** -[NSCFArray initWithObjects:count:]: attempt to insert nil object at objects[0]

和控制没来acceptDrop方法,

当我启用了“停止对异常”以下是调用堆栈,当它停了下来,

#0  0x981b94e6 in objc_exception_throw
#1  0x96ed34cf in -[__NSPlaceholderArray initWithObjects:count:]
#2  0x96efaaa3 in +[NSArray arrayWithObject:]
#3  0x92316dfd in -[NSOutlineView _columnsForDragImage]
#4  0x923f1e32 in -[NSTableView _doImageDragUsingRowsWithIndexes:event:pasteboard:source:slideBack:startRow:]
#5  0x91fea16a in -[NSTableView _performDragFromMouseDown:]
#6  0x91fe89b9 in -[NSTableView mouseDown:]
#7  0x91fe864e in -[NSOutlineView mouseDown:]
#8  0x91f86c68 in -[NSWindow sendEvent:]
#9  0x91e9f817 in -[NSApplication sendEvent:]
#10 0x91e332a7 in -[NSApplication run]
#11 0x91e2b2d9 in NSApplicationMain

让我更新一两件事,在我的大纲视图,我有自定义单元格,这是什么,但我使用的是Mac ImageTextCell接口文件。

任何人都可以请指导我,我在做什么错

亲切的问候罗汉

Answer 1:

[myoutlineView setOutlineColoumn:firstColumn]失踪,当我再补充其tarted工作



Answer 2:

请确保你已经“停止对Objective-C的异常”在Xcode的调试菜单打开,然后运行调试器下您的应用程序(使用断点启用)。 当异常得到投掷调试器将停止,然后你可以调查,你要创建一个数组nil对象。

我觉得不可能,你已经显示的代码是问题的根源,因为你逝去的是是AppKit框架全局定义的字符串。



文章来源: Regarding NSoutlineView and WriteItem | Drag-and-Drop Problem