When I took up writing this blog, I was prepared to get spam in the comments. I’ve deleted quite a few so far. But when I got one that said “Super post, Need to mark it on Digg”, I have to admit, I almost approved it by default. That seems like just “nice article” compliment.
But, being the person I am, and having experienced so many people trying to trick me, I looked at the site in the commentor’s URL. It was a site in a language I couldn’t read, but the format suggested that it was a sales site of some kind.
So the surprise? I Googled for the exact string (with quotes) “Super post, Need to mark it on Digg” and got over 16,000 results. This exact string appears in blog after blog. The name and URL changes in the blogs I examined, but it always leads to some sales site.
Well, it was a surprise to me.
Funny one today: my default.png file would not display. My application launched with a black screen zooming out instead. A quick look at another app that did work properly showed the only difference: the “D” was capitolized. A quick check and sure enough, it worked if the D was upper-case.
That was a surprise to me, being so used to the case-insensitive file system on the Mac for so long.
DevBits06: Debugging with Instruments causes Bugs?
After a LOT of work going over code trying to find the problem, I was thinking it must be something device-specific because it hadn’t happened in the simulator at all. I looked through all my notes, I looked through posts online, nothing seemed to narrow it down.
Now, with all the logging, I finally see that the index was jumping by 2 rather than 1 at wrong moments. That was sending the index beyond the limit. Now Why? WHY? The only increment code was in an IBACTION called by a button on the view, and it only incremented by 1.
In the end, I could hardly believe the answer: I was incrementing by 1 – TWICE. The IBACTION was being called multiple times by MY rapid clicking (touching) on the button. I thought it was cool that while the animation was transitioning between 2 views, the destination view was actually loaded and ready to be touched. It made everything faster. I was going through views at a rapid pace in my testing and thinking nothing of it. Every new touch would interrupt the animation and do whatever the touch would do. Most of the time, the offending view would disappear before the button could be pushed again. However, with Instruments running, things on the device slowed down just enough for the button to sometimes get pushed again and send the message to the IBACTION a second time. The indexes incremented incorrectly as a result.
The first thought I had was “I shouldn’t use Touch-Up-Inside. I should send the event on Value-Changed or something”. That might have worked, but the button in question was a button bar item. It didn’t have the option to choose the event.
The solution: add some code to the program to prevent incrementing beyond the array bounds.
The solution I probably should have used (and will use in the next version): add code to the IBACTION to prevent it from executing more than once before the view disappears (and re-appears a little later.) I’ll just add a member variable to the view controller that turns false/NO on entering the IBACTION, and resets to true/YES in ViewDidAppear.
The moral: do not assume that an IBACTION can only be called once just because it changes the view or view controller. The system controls that.
Your downloaded certificate file doesn’t seem to contain a private key? You turned down the arrow in the Keychain Utility and there wasn’t anything there? I’ve had this happen twice and I’ve got the following I wrote down. I wish I had written something more detailed at the time, but here is this if it helps.
– the original private key for the request is held on the computer that generated the certificate request (CSR) file, so you must download the certificate on that same computer. (And hopefully a crash or drive corruption hasn’t hurt that key in the meantime.) I’m not an expert on security, but I believe the idea is that the request (CSR) is actually a public key, or contains one, so when Apple creates the certificate, only you can decrypt it with the private key for the CSR.
– Create a different CSR for each certificate: One for development, one for distribution. I’m not exactly positive on this one. I’m wishing I wrote more, but I’m sure that doing this won’t hurt anything.
Remember: to be able to give free updates to your customers, you must have the original distribution private key. Back it up in places that will survive the death, destruction, disappearance and theft of the hard drive it is stored on.
Changed your bundle identifier and now XCode won’t load the result app onto the iPhone or iPod Touch device?
– Try deleting the old version of the application from the device before loading/running the new one.
This one frustrated me for longer than I care to think about. (It wasn’t really all that long, but my pride was hurt that I didn’t figure it out much more quickly.) It appeared to be something wrong in the generated token stream but the messages gave no real clue as to why this was happening. My first thought was that I had accidentally edited an SDK file.
Special thanks to John Muchow for his post on iphonedevelopertips.com which quickly lead me to the correct answer. No doubt you saved me time and hair-pulling.