         if segue.identifier == "presentDetailedNoteView" {
             if let destinationViewController = segue.destinationViewController as? NotesDetailViewController {
                 if let indexPath = tableView.indexPathForSelectedRow {
-                    destinationViewController.note = notes[indexPath.row]
+                    destinationViewController.note = (searchController.active && searchController.searchBar.text != "") ? searchResults[indexPath.row] : notes[indexPath.row]
                 }
             }
         }

    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return notes.count
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("NoteTableViewCell", forIndexPath: indexPath) as! NoteTableViewCell
        
        // Configure the cell...
        cell.titleTextLabel.text = self.notes[indexPath.row].title
        cell.contentTextLabel.text = self.notes[indexPath.row].content
        cell.backgroundColor = UIColor.clearColor()
        
        return cell

    func controllerDidChangeContent(controller: NSFetchedResultsController) {
        tableView.endUpdates()
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
