2011-02-04 83 views
0

爲了處理拖放正下降已經做以下,關於NSoutlineView和WriteItem |拖動和刪除問題

-(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 

讓我更新一兩件事,在我的大綱視圖,我有自定義單元格,這只不過是蘋果我正在使用的ImageTextCell接口文件。

任何人都可以請指導我,我在做什麼錯

親切的問候 羅漢

回答

2

[myoutlineView setOutlineColoumn:firstColumn]失蹤, 當我說那麼它的tarted工作

0

確保已「停止對Objective-C的異常」在Xcode的調試菜單打開,然後運行你的應用程序在調試器下(啓用斷點)。當拋出異常時,調試器將停止,然後您可以調查嘗試使用nil對象創建陣列的位置。

我發現你顯示的代碼不可能是問題的根源,因爲你傳遞的是在AppKit框架中全局定義的字符串。

+0

這是調用堆棧我得到了,在這個問題 – Amitg2k12 2011-02-04 17:36:06