Skip to content

Commit

Permalink
Fix for crash on close after searching
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Filetti committed May 19, 2016
1 parent d4a9716 commit 793c0fe
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions PeyeDF/UI/SearchPanelController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -345,18 +345,22 @@ class SearchPanelController: NSViewController, NSTableViewDataSource, NSTableVie
}

func tableView(tableView: NSTableView, objectValueForTableColumn tableColumn: NSTableColumn?, row: Int) -> AnyObject? {

// check that foundSelections contains valid data first and unwrap values
guard foundSelections.count > row && foundSelections[row].pages().count > 0,
let pages = foundSelections[row].pages() where pages.count > 0,
let page = pages[0] as? PDFPage, document = page.document() else {
return nil
}

if tableColumn?.identifier == kColumnTitlePageLabel {

// get found selection for this row
let pages = foundSelections[row].pages()
let page = pages[0] as! PDFPage
return page.label()

} else if tableColumn?.identifier == kColumnTitlePageNumber {

let pages = foundSelections[row].pages()
let page = pages[0] as! PDFPage
return page.document().indexForPage(page) + 1
return document.indexForPage(page) + 1

} else if tableColumn?.identifier == kColumnTitleLine {

Expand Down

0 comments on commit 793c0fe

Please sign in to comment.