我想將我的應用程序中的數據複製到Numbers或Excel工作表中。數據主要由整數組成,但也包含一些圖像。我試圖通過首先通過該方法把數據在NSTableView的,然後將數據寫入到剪貼板來實現:NSPasteboard:拖拽多個不同類型的對象
- (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pboard
{
NSArray * dataToPaste = [NSArray arrayWithObjects:[NSString stringWithFormat:@"%ld \t %ld \t %ld \t %ld \t %ld \t %ld \t %ld \t %ld \t",
data1,
data2,
data3,
data4,
data5,
data6,
data7,
data8],
[An NSImage], nil];
[pboard writeObjects:dataToPaste];
return YES;
}
如果我沒有在結尾處添加NSImage中,所有的數據是很好的複製,但只要我將NSImage添加到數組中,只有圖像被複制,並且如果我添加兩個NSImages,只有第一個被複制。我錯過了什麼?
任何想法將不勝感激!
編輯:順便說一句,我只是意識到,甚至沒有Numbers.app管理拖拽文本和圖像複製單元既不Excel或TextEdit。數字文件之間的作品然而。
感謝您的建議。但是,對圖像使用%@僅會生成圖像的元數據:「 )> –