Get In Touch
This form does not yet contain any fields.


    Regular Expressions on iOS - NSRegularExpression

    Regular Expressions are a vital part of most developer's toolkits and can be incredibly useful when processing text strings.  Apple recently introduced regular expressions at WWDC 2010 for iOS 4.0 as the framework NSRegularExpression.  I've recently started working with this framework for a project that does some web scraping and created some functions that I think would be useful to most iOS devs.

    This first example will take in a string and will return the first match it finds to the specific regular expression syntax, in this example that expression will find all http URLs.  

    The second example will take a regex pattern, find it in the given string and substitute all matches for that pattern creating a new string when done.  The sample function below will find all whitespace and substitute it for '&'.


    The Best Question is the One Never Asked

    A natural part of being a developer is working through those tough times when you are really stumped and no matter what you do, you cannot solve the problem.  StackOverflow is a great resource for these times and has saved my bacon on numerous occasions, especially on some really tricky issues.  

    Although I began to notice a trend in my workflow, I would get stuck on an issue, try a few things and then head over to StackOverflow to starting writing my question, but as I would put my problem into words, a light would come on. I would get a whole new perspective on the problem.  The exercise of framing the problem in a way that someone else could understand it, forced me to simplify the issue and break it down into digestible components.  By mentally working through the problem it also helped me better retain that solution than if I had simply found the answer through Google.

    The next time you get stuck on a tough issue, take a moment and write down exactly whats going wrong as if you were going to explain it to someone else, you may just notice exactly where you are going wrong and even if you dont, at least you have a question all ready for submission to StackOverflow...


    Reserving your iOS App Name

    One of the more frustrating experiences developing for iOS is completing an entire App and going to publish the App in the App Store and finding out that the name you chose has been taken by another application.  The only process in place today to find out if a name is truely available and/or reserve your name is to create an app on the App Store and wait to upload the binary until you are done with the project.  This method does have a hard limitation of 120 days and if you do not upload a binary by then, Apple deletes the App submission and prevents you from ever registering that name again.  All of this to avoid the same proliferation of name squatting that occurs with domain names. Apple really needs to come up with a better approach for developers that will provide a reasonable accomidation to permit developers to register a name of a project they are working on.

    Dave Wood over at Cerebral Gardens has a good suggestion for a system that would permit developers to reserve up to 10 unused app names per account.  I personally think this is a little high and would probably encourage squatting but I like the general idea and think it could be successful with a smaller number, somewhere around 3 to 5.


    Parsing JSON in iOS the right way

    I thought I would share a little detail that burned me this week.  I'm working on a new project that integrates with Twitter to pull data down from the JSON Search API.  There are a ton of tutorials out there that describe how to use the JSON Framework to parse a JSON resultset with iOS, although one thing I noticed with all the tutorials, is that they are doing this Wrong! 

    A good example is the tutorial from IOS Developer Tips this is actually a really great tutorial for the most part, but there is one error, that leads to epic failure.

    The failure occurs with the usage of

    - (void)connection:(NSURLConnection *)connection 
    didReceiveData:(NSData *)data

    which is the method they are using to act on the JSON results. When I tried to implement this with the Twitter search api, it would sometimes work, and sometimes fail. It was completely random and driving me insane. I would receive these horrid errors from the JSON parser... 

    "Error Domain=org.brautaset.JSON.ErrorDomain Code=5 \ 
    "Unescaped control character '0x0'\"

    This is the worst kind of error because it works sometimes, and fails miserably in others and none of the debug output is really helpful at all.

    Now the reason why this fails is due to the nature of the Asynchronous request setup using NSURLConnection previously in this example.  This will result in the didReceiveData method *possibly* being called multiple times as the data is delivered.  Meaning sometimes I would get a whole JSON data string that the parser could parse fine, but sometimes I would end up attempting to parse the fragments of the JSON string that had been downloaded so far, thus resulting in failure.

    The right way to implement this is to create an NSMutableData object and when the didReceiveData method is called, append the result data to the NSMutableData object.  Then utilize the connectionDidFinish method of NSURLConnection, to parse the resulting and now complete dataset.

    Special thanks to  for the guidance on this one...


    Don't write down feature requests!

    While reading the great book from 37 Signals Rework I came across an interesting suggestion, "Don't write down feature requests." This seemed to go against my natural instincts to write down all suggestions, because if some wants it, I should put it in right?

    Well as Traceroute Pro went out to the public and I started hearing back from users, I didn't listen to the suggestion and started writing down all the feature requests. "I think there should be a dancing unicorn in the background to entertain me while I wait for the results." Err ok...

    So needless to say after getting a few crazy requests, Jason's words started to resonate with me.

    What I've found is that the best way to approach it is to just read all requests, and then throw them away. If they are good ideas and valid suggestions, you will hear them a few times and they will stick.

    I used this approach with the latest update for Traceroute Pro. No it doesn't have that dancing unicorn, but it does have the ability to save sites to your favorites and maintains a full history of your past tests.  These are two of the most requested features that I heard from my users and after I implemented them, I couldnt imagine having created the application without them.