IvanoBilenchi/ICTextView

not working with iOS 8 bridged to swift(

rovnyart opened this issue · 2 comments

Tried demo project on xcode 6 ios 8.1 simulator - works perfectly, but when i try to import .h and .m files to my existing Swift project (with creating a bridge header) - it compiles successfully, but at runtime throws an error:
[UITextView scrollToString:searchOptions:animated:atScrollPosition:]: unrecognized selector sent to instance 0x12d05f400
2014-11-30 22:24:34.125 RTP Helper[1181:193763] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextView scrollToString:searchOptions:animated:atScrollPosition:]: unrecognized selector sent to instance 0x12d05f400'

here is my code:

import UIKit

class TermsViewController: UIViewController, UISearchBarDelegate {

@IBOutlet weak var searchBar: UISearchBar!

@IBOutlet weak var textView: ICTextView!




override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(animated)
    searchBar.becomeFirstResponder()
}



override func viewDidLoad() {
    super.viewDidLoad()

self.automaticallyAdjustsScrollViewInsets = false

    textView.scrollRangeToVisible(NSMakeRange(0, 0))

    searchBar.delegate = self
 }

func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
    if searchText.isEmpty {
        textView.resetSearch()
        return
    }
    textView.scrollToString(searchText, searchOptions: NSRegularExpressionOptions.CaseInsensitive, animated: true, atScrollPosition: ICTextViewScrollPositionMiddle)
}

func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
    textView.becomeFirstResponder()

}
func searchBarSearchButtonClicked(searchBar: UISearchBar) {
    textView.scrollToString(searchBar.text, searchOptions: NSRegularExpressionOptions.CaseInsensitive, animated: true, atScrollPosition: ICTextViewScrollPositionMiddle)
}

func searchBarCancelButtonClicked(searchBar: UISearchBar) {
    searchBar.text = nil
    textView.resetSearch()

}

}

Hey @rovnyart, sorry for the late reply. I haven't started learning Swift yet, as I mostly develop for jailbroken iOS, so I don't know what may be wrong.

The error you're getting happens because the ICTextView instance you're trying to use is actually a normal UITextView (which doesn't respond to the scrollToString:searchOptions:animated:atScrollPosition: selector, thus crashing your app).

Are you sure there are no mistakes on your end? Did you manage to solve this issue?