Sit back, relax, and enjoy the code.

Quick Hits: UIActionSheet cancel button strange behaviour

Posted: July 3rd, 2010 | Author: abel | Filed under: Quick Hits, iPhone | Tags: , , | 1 Comment »

I just got bit by this and fixed it thanks to this StackOverflow post.

http://stackoverflow.com/questions/1197746/uiactionsheet-cancel-button-strange-behaviour

Long story short, if your launch an action sheet in a view that lives in a UITabBarController, the “hit” box for the cancel button gets shifted in a VERY STUPID WAY!

The solution is to reference the view you’re displaying in by the UITabBarController like this:

[sheet showInView:self.parentViewController.tabBarController.view];

Freaking WOW! Thanks a heap, Apple!

*grumble grumble*

  • Share/Bookmark

Quick Hits: Becareful when returning inc’ed vars

Posted: May 1st, 2010 | Author: abel | Filed under: MonoTouch, Programming, Quick Hits | Tags: , | 1 Comment »

I noticed this in some MonoTouch code that I wrote recently, but I think it makes sense across other languages as well.  Let’s say you write a method that returns an incremented variable like this:

private int MyAwesomeFunction(int pVar)
{
// coding magic
return pVar++;
}

…where pVar = 10, the returned value will NOT be 11!  The returned value will still be 10.  If you want to return an incremented value for pVar, do the following:

private int MyAwesomeFunction(int pVar)
{
// coding magic

return ++pVar; // or return pVar+1;
}

Just a case of postfix vs prefix.  In the previous example, the variable never gets incremented because the postfix operator would get evaluated after the line is processed, but that never happens because we’re returning the pVar.  By flipping to a prefix operator, we guarantee that we evaluate the opperator against the variable before we return it.

It’s also worth mentioning that being a little verbose here is also good.  Explicitly stating that you’re adding 1 to the variable (as displayed in the commented code) is the same number of characters and we eliminate the confusion over what’s getting returned.

Happy Coding!

  • Share/Bookmark

The 5 stages of 3.3.1

Posted: April 11th, 2010 | Author: abel | Filed under: MonoTouch | Tags: , , , | 5 Comments »

Developers have been up in arms on the news broken by Daring Fireball and TechCrunch.  The reported change in the iPhone developer agreement definitely stops Flash developers from creating iPhone apps using the new tools available CS5, but the sword Apple used also cuts into the heart of the MonoTouch, Appcelerator, Unity 3D, Corona, & PhoneGap communities.  Being a member of the MonoTouch community, I’m directly affected by this reported change.  Easily said, I’ve gone through the 5 stages of grief over the news:

Read the rest of this entry »

  • Share/Bookmark

Quick Hits: Localization strings in Monotouch

Posted: February 21st, 2010 | Author: abel | Filed under: MonoTouch | Tags: , | No Comments »

It’s pretty straight forward. Check out this post:

Internationalising my app

…and make sure the folders you use follow this format “[Language Abbreviation].lproj” as commenter #4 points out ;)

If you miss one of the major languages, your app will default to English.  As of this post, the iPhone OS supports the following languages:

English (U.S), English (UK), French (France), German, Traditional Chinese, Simplified Chinese, Dutch, Italian, Spanish, Portuguese (Brazil), Portuguese (Portugal), Danish, Swedish, Finnish, Norwegian, Korean, Japanese, Russian, Polish, Turkish, Ukrainian, Arabic, Thai, Czech, Greek, Hebrew, Indonesian, Malay, Romanian, Slovak, and Croatian

  • Share/Bookmark

Quick Hits: When your .gitignore file gets…ignored

Posted: February 6th, 2010 | Author: abel | Filed under: Version Control | Tags: , | No Comments »

I made a mistake while creating a GIT repos that I’m hoping I can save you from making.  I made my first commit on a project and I realized that a bunch of files were getting in that shouldn’t be.  I created a .gitignore file, but the issue kept happening on subsequent commits.  As I learned later, you SHOULD create your .gitignore file first.  However, if you forgot, this is how you fix it:

  1. Keep your .gitignore file.
  2. Clear your GIT cache.  Don’t worry, this won’t delete any of your local files, just what GIT is tracking.
    git rm -r --cached .
  3. Add everything in your project.  Your .gitignore file will exclude what you want to ignore now and start tracking the good stuff.
    git add .
  4. Commit your changes.
    git commit -m "Now my .gitignore file works correctly!"

Happy codding!

  • Share/Bookmark

Quick Hits: Sass demands syntax perfection!

Posted: January 25th, 2010 | Author: abel | Filed under: Quick Hits, Rails | Tags: | No Comments »

Just a quick note about sass.  Let’s say you had the following in /public/stylesheets/sass/foo.sass:

body
  line-height:1.2em

h1
  color:red

This would render a blank document for /public/stylesheets/foo.css.  You won’t get an error about it, you’ll just get a blank document.  Here’s the thing, when you’re declaring a CSS property, you MUST put a space after the colon.  Failing to do so will just wind up in parsing errors on the sass side.

I hope I’ve saved you some head scratching. :-)

  • Share/Bookmark

I LOVE MonoTouch

Posted: January 24th, 2010 | Author: abel | Filed under: MonoTouch | Tags: , , | 1 Comment »

Don’t get me wrong, XCode is great…in it’s own way…but as a .Net dev coming to the iPhone platform, MonoTouch rocks my world!

For the other devs in my shoes looking to play with MonoTouch, here are some things to keep in mind: Read the rest of this entry »

  • Share/Bookmark

iPhone OS 3.0 GM Seed installation steps via iTunes & XCode

Posted: June 9th, 2009 | Author: abel | Filed under: iPhone | Tags: | No Comments »

I couldn’t find these instructions in the iPhone Development portal, so I figured i’d share them with you here.  Once you download the appropriate GM seed, here’s how it’s done (I’m assuming you’ve already designated your phone as a dev device.):

  1. Make sure…
    1. to downloaded correct GM Seed for your iPhone (1st Gen or 3G).
    2. that your system and version of iTunes meet the requirements: 

      “You must be running Mac OS X v10.5.7 and iTunes 8.2 in order to install iPhone SDK 3.0 GM Seed and iPhone OS 3.0 GM Seed.”

      “You must be running Mac OS X Snow Leopard Final Developer Preview (Build 10A380) and iTunes 8.2 in order to install the iPhone SDK 3.0 GM Seed for Snow Leopard and iPhone OS 3.0 GM Seed.”

  2. Extract the firmware .ipsw to a folder.
  3. Connect the iPhone to your computer.
  4. Back up your phone!
  5. Open iTunes and click Restore while holding the Shift key (for Windows) or Option key (for Mac).
  6. Locate or browse to the firmware IPSW.
  7. Wait for iTunes to unpackage and install the firmware.

OR you can just use Xcode…

  1. Back up your phone!
  2. Open Xcode
  3. Open the Organizer (Window -> Organizer)
  4. Flip the software version to “Choose…”
  5. Select the GM Seed ipsw file
  6. You should  see a message that says something like “These changes will take effect when you restore you phone”
  7. Click on the “Restore iPhone” button and watch the magic happen.

By backing up your phone ahead of time, you’ll be able to tell iTunes to put all of your crap back on it when the process is done.  It’ll even try to preserve icon locations :)

Happy hacking.

  • Share/Bookmark

Quick Hits:Deploying iPhone projects to your iPhone/iPod Touch

Posted: June 4th, 2009 | Author: abel | Filed under: Quick Hits, Uncategorized, iPhone | Tags: , , | No Comments »

This process sucks. Period. To get you through the suckage, I found this article with clear and useful steps. If you’re becoming an iPhone/iPod Touch developer, this is something you NEED to read. The article presents the steps of the deployment process in the best order possible to improve your chances at a successful push.

Deploying iPhone Apps to Real Devices

Happy hacking!

  • Share/Bookmark

Quick Hits: A great FAQ for iPhone game developers

Posted: May 30th, 2009 | Author: abel | Filed under: Quick Hits, iPhone | Tags: , | No Comments »

I came across this video from Brian Greenstone, the president and CEO of Pangea Software.  You might remember him from such iPhone games as Enigmo, Cro-Mag Rally, or Bugdom 2.

He’s made a video answering “10,000 ft view” questions about iPhone game development that people who are new to the platform should hear.  What he’s saying isn’t revolutionary, but it’s a lot of very good advice in 1 spot.

Enjoy and happy hacking!

  • Share/Bookmark