Up vote 0 down vote favorite 1 share g+ share fb share tw.
I have an Editable NSTextView,In which user will write using different font style, on certain action I need to prepare the HTML Formate of it, Can anyone suggest me, how I can retrieve the data from NSTextView, I am able to use pInputText textStorage words; but it returns NSArray, from which I am not able to get NSMutableString, Can anyone suggest me the best possible way to retrieve the String/data what user typed and in which format. Cocoa nstextview link|improve this question edited Aug 15 '11 at 14:14GojaN562212 asked Mar 24 '11 at 11:59Rohan 289212 64% accept rate.
Below solutions works for me, - (NSString *)convertUnderlineTextToHTML:(NSAttributedString *)_mString { NSArray * exclude = NSArray arrayWithObjects:@"doctype", @"html", @"head", @"body",@"xml",nil; NSDictionary * htmlAtt = NSDictionary dictionaryWithObjectsAndKeys:NSHTMLTextDocumentType,NSDocumentTypeDocumentAttribute,exclude,NSExcludedElementsDocumentAttribute,nil; NSError * error; NSData * htmlData = _mString dataFromRange:NSMakeRange(0, _mString length) documentAttributes:htmlAtt error:&error; NSString * sdat = NSString alloc initWithData:htmlData encoding:NSUTF8StringEncoding; NSLog(sdat); return sdat; } Where _mString is NSMutableAttributedString *pAttributedString = pInputText textStorage; NSString *pHtml = self convertUnderlineTextToHTML:pAttributedString; Regards Rohan.
NSTextView inherits from NSText, which has a -string method. So pInputText string should do what you want. Alternately, TextStorage is a subclass of NSMutableAttributedString, so if you want an attributed string you can just use the return of pInputText textStorage directly.
Thanks Smorgan, I will check and let you know – Rohan Mar 25 '11 at 4:45.
Since NSTextStorage is a subclass of NSMutableAttributedString which has a method through its superclass NSAttributedString :initWithHTML:baseURL:documentAttributes, you can use this to get what you want. DocumentAttributes can be NULL.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.