Question

My app is a simple blog app. I parse an XML, and build custom HTML code from the parsed parts, and load that HTML into a webview. Not everyone has the same quality of vision, so I am trying to add simple buttonsto add or decrease the font size. Currently, the HTML may look like:

font size=5 The Title.../font font size = 3 The body of text.../font

What I would like to do is take whatever number is listed, and increase or decrease by 1.

Any suggestions on how I can take just those 2 numbers (don't want to increase other numbers that may be in body of article) and increase or decrease incrementally?

Was it helpful?

Solution

I'd recommend stuffing the HTML you parsed out of the XML into a "NSMutableString" object and then hunt through the mutable string object looking for the ranges of all substrings that match the pattern "font size=".

Once you find those ranges, you should be able to get the font sizes and then put them into a "NSInteger" via something like [NSString integerValue] which you can then increment and put back into the mutable string object. Obviously there's some extra detail I'm not thinking too hard about, like how to replace a "9" in the mutable string with a "10" or to tell the difference between a font size of "10" and one that's "100". But at least this should be a good start for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top