Saturday, September 3, 2011

What's the question when there is no question?

Ok, we're at the point now where we actually have a functional app. But, it's really primitive and there are a lot of improvements to be made before we can even think about releasing it. One of the first items to address is when the Japanese words has no Kanji representation. The work-around for this, which I implemented in the Android app, was to just move the kana or alphabetic representation of the word into the kanji field of the object. It's a bit goofy, but it solves the problem pretty effectively. So, how do you check for an empty string? The ever dependable SO provides us with the answer:
You can check if [string length] == 0. This will check if it's a valid but empty string (@"") as well as if its nil, since calling length on nil will also return 0.
So, we can actually do this right at the point where it's read:
question.questionTxt = kanji; question.hiragana = hiragana; if ([question.questionTxt length] == 0){ question.questionTxt = hiragana; }
Let's see if it works...yes, it does, although a particularly long kana string get's truncated. That goes into our bug-list as low priority - there won't be a lot like that.
Ok, that was a quick one. We'll tackle something a quite a bit heavier in the next post.

No comments:

Post a Comment