NextGrowingTextView icon indicating copy to clipboard operation
NextGrowingTextView copied to clipboard

Swift Compiler Error: Type 'UITextView' has no member 'textDidChangeNotification'

Open jvriccione opened this issue 7 years ago • 4 comments

Using v1.4.0 from cocoapods (latest as of the writing of this post).

In the file "NextGrowingInternalTextView.swift", the "addObserver" line from the code snippet below has an error with the name input parameter, saying "Type 'UITextView' has no member 'textDidChangeNotification'."

I have spent hours trying to determine why textDidChangeNotification is not being recognized. I have removed the dependency, added it back, cleaned, and rebuilt multiple times to no avail. Perhaps it is deprecated in Swift 4. Would appreciate some help on this. Thanks!

override init(frame: CGRect, textContainer: NSTextContainer?) {
    super.init(frame: frame, textContainer: textContainer)

    NotificationCenter.default.addObserver(self, selector: #selector(NextGrowingInternalTextView.textDidChangeNotification(_ :)), name: UITextView.textDidChangeNotification, object: self)
  }

jvriccione avatar Sep 25 '18 18:09 jvriccione

I also had same problem. (using Swift4.0) I changed UITextView.textDidChangeNotification into .UITextViewTextDidChange and fixed this issue.

https://github.com/jtaka1012/NextGrowingTextView/commit/232b127cd1aefde5927113b119fb562cb343b9b1

I think that this fix works correctly.

But, I don't know that if this fix will work under Swift 4.2.

jtaka1012 avatar Sep 27 '18 06:09 jtaka1012

i also had same issue facing with swift 4.2.0

techtic-bhavin avatar Oct 19 '18 11:10 techtic-bhavin

NSNotification.Name.UITextViewTextDidChange Swift 4.2

asifSdSol avatar Nov 16 '18 15:11 asifSdSol

thank you @jtaka1012

kayes55 avatar Apr 21 '19 21:04 kayes55