Using % in NSString

It probably says this somewhere, but I missed it. I’m writing results to the screen and to a file and it works fine with this code for my table headers:

tableHeader = @"<table width='100%' border='1'><tr><th colspan='2'>Presentations</th></tr>";

I wanted to adjust the colspan depending on the number of presentations for different conditions. So I put the code into an NSString like so:

NSInteger numColumns = 6;
tableHeader = [NSString stringWithFormat:@"<table width='100%' border='1'><tr><th colspan='%d'>Presentations</th></tr>", numColumns];

The table no longer takes up the whole page. I tried escaping the 100% like you normally do \% but that didn’t do anything. The correct way to escape a percent sign is to double it. e.g. %%

So now you know.

Apple Store App is Now Available

FAA Glossaries is now available on the App Store.

This app is a collection of Glossaries found in FAA publications for pilots. It includes words, terms, and acronyms from seven FAA books: Handbook of Aeronautical Knowledge, Airplane Flying Handbook, Instrument Flying Handbook, Instrument Procedures Handbook, Aircraft Weight and Balance Handbook, Aviation Instructor’s Handbook, and Aviation Weather. It also includes the acronyms from the AIM, the complete Pilot/Controller Glossary, ATC Glossary, and definitions from the FARs—TITLE 14–Aeronautics and Space.

Get FAA Glossaries from the Apple App store!