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:
- i sure using
nstextfield. , set break point inside controltextdidchange: method. called, should have known. - i did control-drag text field delegate object, , print delegate object in
textdidchange:method, sure delegate set correctly. - the other delegate methods, such
controltextdidbeginediting:called correctly.controltextdidchange:not called - i tried comment out over-written in subclassed
nstextfieldclass,controltextdidchange:called. - therefore quite sure not overwritting
textdidchange:right. not known how fix it. - 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
Post a Comment