objective c - How to overwrite textDidChange: method correctly? -


i subclassed nstextfield , overwrite textdidchange: as:

- (void)textdidchange:(nsnotification *)notification {     // ... own operation } 

but when drag input text box .xib file , control drag class assign delegate found delegate's controltextdidchange: method never called.

now tryingto solve problem, tried 2 ways al below:

i. calling super:

- (void)textdidchange:(nsnotification *)notification {     // ... own operation     [super textdidchange:notification]; } 

but got error in runtime: attempt insert nil object objects[0]

ii. calling delegate's method

- (void)textdidchange:(nsnotification *)notification {     // ... own operation     if ([self.delegate responsetoselector:@selector(controltextdidchange:)])     {         [self.delegate ...];    // <--- opps, not happerned here.     } } 

what not happerned? expected auto-complete should display controltextdidchange: method @ position of ... above. did not, actually. typed method directly, compilation fail because method not found.

how should make sub-class call delegate normally? how should overwrite textdidchange: method correctly?


further question vytautas:

  1. i sure using nstextfield. , set break point inside controltextdidchange: method. called, should have known.
  2. i did control-drag text field delegate object, , print delegate object in textdidchange: method, sure delegate set correctly.
  3. the other delegate methods, such controltextdidbeginediting: called correctly. controltextdidchange: not called
  4. i tried comment out over-written in subclassed nstextfield class, controltextdidchange: called.
  5. therefore quite sure not overwritting textdidchange: right. not known how fix it.
  6. what made me confused why auto-completion did not show controltextdidchange: method when attempted call it.

about auto-completion, here how showed:

http://i44.tinypic.com/11rxh5f.jpg

no - controltextdidchange: method.


2nd further reply vytautas:

i tried calling '[self controltextdidchange]' did not work, , error occurred (as highlighted below): http://oi41.tinypic.com/9i9pmx.jpg

i can - controltextdidchange: called sure.

maybe there wrong bindings in *.xib.

also can in *.xib using nstextview, not nstextfield.

in case - controltextdidchange: won't called sure. if case should take nstextview, nstextviewdelegate , nstextdelegate. nstextview delegate has alternative method - textdidchange:


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -