Below is the code which I am using and working fine in simulator iOS 5+, but giving issue in simulator 4.3
UITextPosition *begin = [self.tvQuestion positionFromPosition:self.tvQuestion.beginningOfDocument offset:nrange.location];
Following is the error statement:
Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[UITextView beginningOfDocument]: unrecognized selector sent to instance 0x5586050’
Could somebody advice on this? Thanks in advance!
The
UITextInputprotocol includes abeginningOfDocumentselector since iOS 3.2.But
UITextViewonly adoptedUITextInputsince iOS 5.0. It was previously conforming to theUITextInputTraitsprotocol.Source: search for UITextView here http://developer.apple.com/library/ios/#releasenotes/General/iOS50APIDiff/index.html
If you want it to work on iOS 4.x and later, you have to perform a check and do the computation by yourself on iOS 4: