Archive for Snippets
A lot of applications you see have an email button. When you click it then it will leave the application and take you to the Mail application. It can get really annoying leaving the application and then going back in after your done sending the email. This is just a great way to show off your app and make your app look more professional and make it easier on the user by filling in the To and Subject for them. …
As many of you may have seen by now, there are quite a few ways to find the documents directory on the iPhone. For those of you who don’t know, the documents directory of an app is the location where you should save your application data. While finding the documents directory is a trivial task, it is very important when coding most applications. Apple has provided quite a few ways for resolving the path to this directory.
If …
Introduction
Hey guys. This post is in response to a comment made in my last post about NSTimers. Techy asked if we could do a post on how to take screenshots programmatically using the iPhone SDK. For this minor project we will be creating a small web browser application that will start at www.google.com, and have a button on a toolbar at the bottom to take a picture of the web view and save …
Introduction
Hey guys. So usually the posts we put up here involve screencasts and presentations, but we are going to start also posting small less time consuming pieces for the site. Today I bring to you a small project involving NSTimers. Today we are going to build an app that represents a horse race. We will create a view with 6 small UIView squares with a blue background at the bottom of the screen, we will use a timer to move …
The code below will prevent the iPhone from dimming its screen and ultimately going to sleep. Use it wisely as you don’t want your application becoming notorious for being a battery hog
[UIApplication sharedApplication].idleTimerDisabled = YES;
Happy iCoding!
Have you been curious about how to open Mail.app from your applications to send contact email? Today, I will be teaching you how to do just that. We will even be pre-filling the subject, to line, and body of the email.
This is a great way to to put a contact or bug report button on your app. I’m going to start with a simple UI that I created. I’m not going to discuss how it was created …
Saving and Reloading from .plist files…
A great way to store dictionary data that does not change during runtime is in a .plist file. Say you want to organize some data hierarchically or you want to store the navigation structure of a drill-down somewhere more convenient (see drill-down save example in apple docs), then a .plist file is a great way to go.
Here’s a quick example of how to restore data from a plist file. I’ll use a plist …
It’s times like this, that I miss ruby.
I’m checking a url to see if it has a substring. It would be so easy if this was ruby:
absolute_url.match(/my regex/).any?
In Objective C, you have to use rangeOfString which returns a range. If I were to run this on the string “the quick brown fox” with an argument of “brown” it would return {10,14}. If it’s not found, it would return {NSNotFound, 0}. Let’s use that to check to …
Problem:
You use the applicationDidFinishLaunching method to kick off your application. This event fires automatically on your delegate whenever your app launches.
If your app launches from a special url schema (tel://, http://, mailto://), then another event is fired:
handleOpenUrl
As you might have noticed in the LaunchMe sample project that ships with Xcode, these two methods will most likely conflict.
Solution:
Move the functionality from applicationDidFinishLaunching and put it in another method, like postLaunch. Then add a member variable to the application delegate …