• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Converting an NSAttributedString into an html string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Converting an NSAttributedString into an html string


  • Subject: Converting an NSAttributedString into an html string
  • From: Gustavo Pizano <email@hidden>
  • Date: Fri, 15 Jan 2010 14:00:20 +0100

Hello all.

Well I asked this in the webkit list, to see how webkit does the trick, there Darin (thank if you are somewhere here also) told me that I could use the method :\

- (NSData *)dataFromRange:(NSRange)range documentAttributes:(NSDictionary *)dict error:(NSError**)error

from the NSAtributedString, so this is what I have done..

	NSDictionary * htmlAtt = [NSDictionary dictionaryWithObject:NSHTMLTextDocumentType forKey:NSDocumentTypeDocumentAttribute];
	NSError * error;
	NSData * htmlData = [_mString dataFromRange:NSMakeRange(0, [_mString length]) documentAttributes:htmlAtt error:&error];
	NSAttributedString * htmlString = [[NSAttributedString alloc] initWithData:htmlData options:nil documentAttributes:&htmlAtt error:&error];

in htmlData, I have DATa .. :P. but know I need to get the html formatted string, I mean, if Im right and Darin understood my quesiton good, is .. will this return me something with the html tags.. let's say, I have in a NSAttributedString this   HELLOHELLOHELLOHELLO...  will I get the proper string with html tags as webkit does when saving something? if yes.. then wheat am I missing because right now Im getting the HELLOHELLOHELLOHELLO \n in the htmlString variable.

Any help will be appreciated it..

Thanks


Gustavo

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Converting an NSAttributedString into an html string
      • From: Gustavo Pizano <email@hidden>
  • Prev by Date: Re: Time to drop PowerPC support?
  • Next by Date: Re: Converting an NSAttributedString into an html string
  • Previous by thread: Re: newbie question -views and MCV model
  • Next by thread: Re: Converting an NSAttributedString into an html string
  • Index(es):
    • Date
    • Thread