5 Replies
      Latest reply: Oct 21, 2016 2:28 AM by ak1982 RSS
      ak1982 Level 1 Level 1 (0 points)

        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

        • Re: Error: Value of type '(NSTableView!, objectValueForTableColumn: NSTableColumn!, row: Int) -> AnyObject!' has no member 'select
          eskimo Apple Staff Apple Staff (6,665 points)

          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"

          • Re: Error: Value of type '(NSTableView!, objectValueForTableColumn: NSTableColumn!, row: Int) -> AnyObject!' has no member 'select
            OOPer Level 7 Level 7 (3,395 points)

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

            • Re: Error: Value of type '(NSTableView!, objectValueForTableColumn: NSTableColumn!, row: Int) -> AnyObject!' has no member 'select
              ak1982 Level 1 Level 1 (0 points)

              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) 
                  
                  } 
              
              
                • Re: Error: Value of type '(NSTableView!, objectValueForTableColumn: NSTableColumn!, row: Int) -> AnyObject!' has no member 'select
                  ak1982 Level 1 Level 1 (0 points)

                  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)
                           
                          }
                        }
                  
                • Re: Error: Value of type '(NSTableView!, objectValueForTableColumn: NSTableColumn!, row: Int) -> AnyObject!' has no member 'select
                  ak1982 Level 1 Level 1 (0 points)

                  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.