Error: Value of type '(NSTableView!, objectValueForTableColumn: NSTableColumn!, row: Int) -> AnyObject!' has no member 'select

What is here the problem and how to solve?


    func copy(sender: AnyObject?){
      
        var textToDisplayInPasteboard = ""
        let indexSet = tableView.selectedRowIndexes
        for (_, rowIndex) in indexSet.enumerate() {
            var iterator: CoreDataOjectType
            iterator=tableDataSource.objectAtIndex(rowIndex)
            textToDisplayInPasteboard = (iterator.name)!
        }
        let pasteBoard = NSPasteboard.generalPasteboard()
        pasteBoard.clearContents()
        pasteBoard.setString(textToDisplayInPasteboard, forType:NSPasteboardTypeString)
      
    }



Error: Value of type '(NSTableView!, objectValueForTableColumn: NSTableColumn!, row: Int) -> AnyObject!' has no member 'select

Replies

What line do you get that error on?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

The problem is related to how you declared `tableView`. Please show relevant parts of your code.

Here is the code.


    func tableViewSelectionDidChange(notification: NSNotification) { 
        let myTableViewFromNotification = notification.object as! NSTableView 
        / 
        let indexes = myTableViewFromNotification.selectedRowIndexes 
        var index = indexes.firstIndex 
        while index != NSNotFound { 
            mySelectedRows.append(index) 
            index = indexes.indexGreaterThanIndex(index) 
        } 
        print(mySelectedRows) 
    } 
    
    func copy(sender: AnyObject?){ 
       
        var textToDisplayInPasteboard = "" 
        let indexSet = mySelectedRows 
        for (_, rowIndex) in indexSet.enumerate() { 
            var iterator: CoreDataOjectType 
            iterator=tableDataSource.objectAtIndex(rowIndex) 
           textToDisplayInPasteboard = (iterator.name)! 
        } 
        let pasteBoard = NSPasteboard.generalPasteboard() 
        pasteBoard.clearContents() 
        pasteBoard.setString(textToDisplayInPasteboard, forType:NSPasteboardTypeString) 
    
    }

I get the problem with the index.Set and selected Rows.

But now the error is:


1.) Use of undeclared type 'CoreDataOjectType'

2.) Use of unresolved identifier 'tableDataSource'


Here is some more code


extension FourthViewController: NSTableViewDataSource, NSTableViewDelegate {

    /
    func numberOfRowsInTableView(tableView: NSTableView) -> Int {
        let numberOfRows:Int = getDataArray().count
        return numberOfRows
    }

    func tableView(tableView: NSTableView!, objectValueForTableColumn tableColumn: NSTableColumn!, row: Int) -> AnyObject!
    {
     
        let newString = getDataArray().objectAtIndex(row).objectForKey(tableColumn.identifier)
        return newString;
    /
        func copy(sender: AnyObject?){
         
            var textToDisplayInPasteboard = ""
            let indexSet = tableView.selectedRowIndexes
            for (_, rowIndex) in indexSet.enumerate() {
                var iterator: CoreDataOjectType
                iterator=tableDataSource.objectAtIndex(rowIndex)
                textToDisplayInPasteboard = (iterator.name)!
            }
            let pasteBoard = NSPasteboard.generalPasteboard()
            pasteBoard.clearContents()
            pasteBoard.setString(textToDisplayInPasteboard, forType:NSPasteboardTypeString)
         
        }
      }

Now I stopped one of the two errors:


i set:


                iterator=getDataArray().objectAtIndex(rowIndex)


this should work, or?

But the other error is stll there.