Friday, June 15, 2012

Add Localized Help Files Maintaining Subfolder Hierarchy in XCode 4

One of my projects has localized help files for the app.  When the help was originally designed, it was put into subfolders for major help topics.  That didn't really cause any problems until I migrated it into XCode 4.  There it took a little bit of experimentation before I figured it out.

Basically I had to
  1. Click on the target
  2. Select File->Add Files to...
  3. Add the en.lproj/help directory and then make sure to Create folder references for any added folders
  4. Then, select the newly created blue help item in the project navigator and then click on the File->Add Files to.. for the other languages (e.g., es.lproj/help) etc.  If you try to do this by clicking on the target first (instead of the help item in the navigator) it'll cause a compiler error since it (apparently) tries to overwrite the subdirectories

Wednesday, April 25, 2012

WWDC 2012 - A Guide For Those That Can't Go

For those of us that didn't get WWDC tickets, I've decided to write up some tips to make us feel like we're there (based on my experience the last two years). So let's keep our chins up, eh? Here goes:

    NOW

  1. Send me $1600.00. Part of WWDC's mystique is writing a large check for others to tell you what to do. This is a necessary step. Make sure you do it.

    THE DAY BEFORE

  2. Register. Have your S.O. misspell your name on a small piece of paper and attach it with a shoestring. Write WWDC 2012 on a piece of clothing (jacket, t-shirt) and wear it EVERYWHERE for the next five days.

    THE FIRST DAY

  3. Form a single file line outside of your house (you may need to draw on kids, pets, etc). This will simulate the early gathering of dedicated engineers outside of Moscone before the keynote speech. While Tim Cook might not be as big of a draw as Steve was (RIP Steve), you may still want to get in line no later than 11PM the night before; you'll want to be able to sit up front.

    If you can get a neighbor to walk down your "line" and offer you magazines no one reads, that would be ideal.

  4. Once inside Moscone (your house) walk into a small closet filled with clothes, lukewarm coffee, a few bagel fragments and a banana. This represents the "pre-keynote" activity where everyone is standing in the grand hallways. It does get a little tight. Stand there until you get tired, and then sit down and pull out your laptop. Complain about the Wifi.
  5. After 50 minutes or so, get up and walk out of the closet and go upstairs for the keynote. Hurry and find a seat. Stragglers will need to stay downstairs in "the overflow room" since the ballroom will be filled.
  6. When the keynote starts, you may find yourself clapping for no particular reason. Write something clever on your iPad and hold it over your head. Smile a lot. You're at WWDC!!!

    POST-KEYNOTE LUNCH

  7. Go downstairs. Form a line in front of a table with 5000 boxes of food. After 15 minutes, grab a box of food and attempt to find a seat. Sit on the floor if there are no tables. You can get a drink but, for maximum realism, you should only stock Diet Sprite.

    ATTEND A SESSION

  8. Pick a session and form a line outside your den.

    Uh oh. You're turned away at the door; this session is full. Stand in line outside your bedroom instead. Listen to a session talking about hardware optimization on the Newton. It's okay to leave early.

    OTHER ACTIVITIES

  9. Set up a pseudo Apple knick-knacks and branded clothing store. Be sure to overcharge yourself.

    ATTEND THE THURSDAY NIGHT EVENT

  10. Hang out with 5,000 of your closest friends and listen to a band only five of you have ever heard of. Smile a lot. You're at WWDC!!!
Seriously though, I enjoyed (and learned a lot at) WWDC the last couple of years. Maybe I'll go again next year :)

Saturday, April 7, 2012

presentModalViewController prevents release of other view controllers

Not totally sure what's going on, but I have a split view with a control panel on the left and a detail panel on the right. I have a situation where I want to clear the detail panel and then popup a modal view controller. However, it looks like the modal view controller is somehow causing another retain to be added to the view controller in the detail panel, and then it never releases it.

If I clear the detail panel AFTER calling presentModalViewController, then the detail panel view controller is cleared normally.

Tuesday, March 6, 2012

Sooner or later I'll learn. Force a memory error when testing

Because in the real world, when a memory warning causes the parent windows to give up their resources, it causes viewDidLoad to be run again when the parent view appears. This can cause oddball side effects so this should be tested with every app before release.

Sunday, February 26, 2012

More text encoding issues

Is it me or is TextEdit for the mac just not very good at figuring out text encodings?

I'm trying to create a new HTML file from a word doc that has spanish characters in it. If I cut and paste into TextEdit, that works/looks fine, but if I try to display in Safari the character mapping is off. However if I then save the TextEdit file as UTF-8 and then use iconv to convert to ISO-8859-1, then all is fine. Trying to save the TextEdit file as Western OS doesn't do the trick.

I did try to add a meta charset tag to the HTML, but either I did it wrong or it was ignored.

Wednesday, January 11, 2012

Perl, UTF-8, and TextEdit character encoding hell

I'm working on a project where I need to dynamically read in content from a flat file. The flat file contains some template information and then I'm also pasting in the contents (using TextEdit) of a file that was generated using Perl database access.

The problem was that when I read it into a string using stringWithContentsOfFile and NSUTF8StringEncoding it would blow up. I could use NSASCIIStringEncoding, but then some of the characters (e.g em dash, single double quote) were translated incorrectly. If I brought this file up in TextEdit or Dashcode, everything looked great. Displaying the file in vi or the command line did not.

When I did a file -I foo.txt it reported the file type was "unknown" although the Perl generated file was utf-8.

I traced the problem down to the TextEdit "Plain Text File Encoding" preferences. Both "Opening Files" and "Saving Files" were set to UTF-8. This was helpful to read the data, but somehow when saving the pasted-in content, it caused the file type to get hosed such that certain tools (e.g. my command window which is set to UTF-8) could no longer properly read the characters.

Once I set the preferences back to automatic, the saved file is now utf-8, but the special characters don't display correctly in TextEdit. The file also loads with UTF8 encoding into an NSString.

Weird.

That's three hours of my life I'll never get back.