I have RTF text which I am showing to the user on Mac. Now I need to replace some text. The text has some images inline. When I execute the following code, the images are getting lost. I am using c#, Mono and Monobjc to run this on mac.
NSText _questionView;
// some initialisation code which I have skipped
//
NSRange range = NSRange.NSMakeRange(0, _questionView.TextStorage.Length);
NSData oldString = _questionView.RTFFromRange(range);
if (oldString != null)
{
string s = oldString.ConvertRTFToString();
_questionView.ReplaceCharactersInRangeWithRTF(range, s.ConvertToNSData());
_questionView.SelectedRange = NSRange.NSMakeRange(0,0);
// After this line the inline images are lost.
}