<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jeff Kelley’s Blog</title>
	<atom:link href="http://blog.slaunchaman.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.slaunchaman.com</link>
	<description>Mac tips, iPhone applications, and the like</description>
	<lastBuildDate>Wed, 10 Mar 2010 02:28:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>New iPhone Project: uWarranty</title>
		<link>http://blog.slaunchaman.com/2010/03/09/new-iphone-project-uwarranty/</link>
		<comments>http://blog.slaunchaman.com/2010/03/09/new-iphone-project-uwarranty/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 17:56:59 +0000</pubDate>
		<dc:creator>Jeff Kelley</dc:creator>
				<category><![CDATA[My Software]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa Touch]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[open-source]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[uWarranty]]></category>

		<guid isPermaLink="false">http://blog.slaunchaman.com/?p=244</guid>
		<description><![CDATA[So, I created a new iPhone application called uWarranty. It used an unpublished Apple API for warranty status (from selfsolve.apple.com), and so I got this after submitting it:
Thank you for submitting your application to the App Store. Unfortunately, your application, uWarranty, cannot be added to the App Store because it violates section 3.3.7 of the [...]]]></description>
			<content:encoded><![CDATA[<p>So, I created a new iPhone application called uWarranty. It used an unpublished Apple API for warranty status (from selfsolve.apple.com), and so I got this after submitting it:</p>
<blockquote><p>Thank you for submitting your application to the App Store. Unfortunately, your application, uWarranty, cannot be added to the App Store because it violates section 3.3.7 of the iPhone Developer Program License Agreement:</p>
<p>&#8220;Applications may not perform any functions or link to any content or use any robot, spider, site search or other retrieval application or device to scrape, retrieve or index services provided by Apple or its licensors, or to collect, disseminate or use information about users for any unauthorized purpose.&#8221;</p></blockquote>
<p>OK, I get it. That&rsquo;s fine and is Apple&rsquo;s prerogative. But now I have this program and all the development time that went into it. So what do I do? I guess the answer is to open-source it, just like <a title="AppSales Mobile" href="http://github.com/omz/AppSales-Mobile" target="_blank">AppSales Mobile</a>. Watch this space for more details as I clean up the code and throw it up on a public repository somewhere.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.slaunchaman.com/2010/03/09/new-iphone-project-uwarranty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cocoa Touch Tutorial: Stripping Non-Alphanumeric Characters on Entry in a UITextField</title>
		<link>http://blog.slaunchaman.com/2010/02/26/cocoa-touch-tutorial-stripping-non-alphanumeric-characters-on-entry-in-a-uitextfield/</link>
		<comments>http://blog.slaunchaman.com/2010/02/26/cocoa-touch-tutorial-stripping-non-alphanumeric-characters-on-entry-in-a-uitextfield/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 06:14:15 +0000</pubDate>
		<dc:creator>Jeff Kelley</dc:creator>
				<category><![CDATA[Programming Tutorials]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa Touch]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[NSCharacterSet]]></category>
		<category><![CDATA[NSMutableString]]></category>
		<category><![CDATA[NSString]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[UITextField]]></category>
		<category><![CDATA[UITextFieldDelegate]]></category>

		<guid isPermaLink="false">http://blog.slaunchaman.com/?p=216</guid>
		<description><![CDATA[In a previous post, I showed you how to trim non-alphanumeric characters from a string. Here I&#8217;ll go more in-depth and show a method that I wrote to restrict text entry in a UITextField to alphanumeric characters. Since I also wanted the characters to be uppercase, I&#8217;ll also ensure that only uppercase characters are allowed.
This [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a href="http://blog.slaunchaman.com/2009/11/01/cocoa-tutorial-strip-non-alphanumeric-characters-from-an-nsstring/">previous post</a>, I showed you how to trim non-alphanumeric characters from a string. Here I&rsquo;ll go more in-depth and show a method that I wrote to restrict text entry in a <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITextField_Class/Reference/UITextField.html"><code>UITextField</code></a> to alphanumeric characters. Since I also wanted the characters to be uppercase, I&rsquo;ll also ensure that only uppercase characters are allowed.</p>
<p>This should all happen in the <em><code>-&nbsp;(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string</code></em> method of your <code>UITextField</code>&rsquo;s delegate (which, of course, must implement the <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITextFieldDelegate_Protocol/UITextFieldDelegate/UITextFieldDelegate.html"><code>UITextFieldDelegate</code> protocol</a>). I&rsquo;ve implemented it as follows:</p>
<blockquote><pre>- ( BOOL )textField:( UITextField * )textField
shouldChangeCharactersInRange:( NSRange )range
  replacementString:( NSString * )string
{
    /*
     * We only want uppercase letters and numbers in this text field, so if
     * this method is adding something else, we don't want it. But we also
     * want to support copy-and-paste, so it's not always going to be one
     * character added.
     */
    BOOL shouldAllowChange = YES;</pre>
</blockquote>
<p>The <em><code>shouldAllowChange</code></em> variable is set to <code>YES</code> initially because we <em>want</em> to allow this change when possible. The method will test the string to see if it meets criteria for rejection as we move forward.</p>
<blockquote><pre>    NSMutableString *newReplacement =
    [[ NSMutableString alloc ] initWithString:[ string uppercaseString ]];

    if ( ! [ string isEqualToString:newReplacement ]) {
        shouldAllowChange = NO;
    }</pre>
</blockquote>
<p>First, we define <em><code>newReplacement</code></em>. It&rsquo;s an <a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSMutableString_Class/Reference/Reference.html"><code>NSMutableString</code></a> so that if we discover non-alphanumeric characters in it, we can remove them on-the-fly. It also serves as a convenient string against which we can test to see if <code>string</code> is already uppercase.</p>
<blockquote><pre>    NSCharacterSet *desiredCharacters =
    [ NSCharacterSet alphanumericCharacterSet ];

    for ( NSUInteger i = 0; i < [ newReplacement length ]; i++ ) {
        unichar currentCharacter = [ newReplacement characterAtIndex:i ];

        if ( ! [ desiredCharacters characterIsMember:currentCharacter ]) {
            shouldAllowChange = NO;
            [ newReplacement deleteCharactersInRange:NSMakeRange( i, 1 )];
            i--;
        }
    }</pre>
</blockquote>
<p>In this section, we define the <a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSCharacterSet_Class/Reference/Reference.html"><code>NSCharacterSet</code></a> that we want to work with - in this case, the alphanumeric character set. We go through one character by a time and if the current character isn&rsquo;t alphanumeric, we remove it from the <code>NSMutableString</code> (decrementing <em><code>i</code></em> so that we don&rsquo;t inadvertently skip a character) and set our <code>shouldAllowChange</code> flag accordingly.</p>
<blockquote><pre>    if ( shouldAllowChange ) {
        [ newReplacement release ];
        return YES;
    } else {
        [ textField setText:[[ textField text ]
                             stringByReplacingCharactersInRange:range
                             withString:newReplacement ]];
        [ newReplacement release ];
        return NO;
    }
}</pre>
</blockquote>
<p>To finish, if <code>shouldAllowChange</code> is still true, we return <code>YES</code> and allow the replacement characters to be added. Otherwise, we return <code>NO</code>, but not before using our replacement replacement string (say that ten times fast) to manually edit the text field&rsquo;s text. The end result is a text field that will consist only of uppercase letters and numbers.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.slaunchaman.com/2010/02/26/cocoa-touch-tutorial-stripping-non-alphanumeric-characters-on-entry-in-a-uitextfield/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>User Accounts Disabled</title>
		<link>http://blog.slaunchaman.com/2010/02/21/user-accounts-disabled/</link>
		<comments>http://blog.slaunchaman.com/2010/02/21/user-accounts-disabled/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 01:56:24 +0000</pubDate>
		<dc:creator>Jeff Kelley</dc:creator>
				<category><![CDATA[Miscellania]]></category>
		<category><![CDATA[admin]]></category>

		<guid isPermaLink="false">http://blog.slaunchaman.com/?p=208</guid>
		<description><![CDATA[To help fight spam, I&#8217;ve disabled user account registration on this blog and deleted all subscribers. I apologize if anyone actually used that feature; if RSS isn&#8217;t enough for you, e-mail me and I&#8217;ll make you an account. Unless you try to sell me Viagra.
]]></description>
			<content:encoded><![CDATA[<p>To help fight spam, I&#8217;ve disabled user account registration on this blog and deleted all subscribers. I apologize if anyone actually used that feature; if RSS isn&#8217;t enough for you, e-mail me and I&#8217;ll make you an account. Unless you try to sell me Viagra.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.slaunchaman.com/2010/02/21/user-accounts-disabled/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Apple&#8217;s SimplePing on iPhone OS</title>
		<link>http://blog.slaunchaman.com/2010/02/13/using-apples-simpleping-on-iphone-os/</link>
		<comments>http://blog.slaunchaman.com/2010/02/13/using-apples-simpleping-on-iphone-os/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 19:06:48 +0000</pubDate>
		<dc:creator>Jeff Kelley</dc:creator>
				<category><![CDATA[Programming Tutorials]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[ping]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://blog.slaunchaman.com/?p=203</guid>
		<description><![CDATA[If you try out of the box to compile Apple&#8217;s &#8220;SimplePing&#8221; code sample on the iPhone OS, you&#8217;ll wind up with a lot of errors as some files don&#8217;t exist in those SDKs. Specifically, you need these files (you need more than just these files to compile, obviously, but these are the ones that aren&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>If you try out of the box to compile Apple&rsquo;s &ldquo;<a href="http://developer.apple.com/mac/library/samplecode/SimplePing/">SimplePing</a>&rdquo; code sample on the iPhone OS, you&rsquo;ll wind up with a lot of errors as some files don&rsquo;t exist in those SDKs. Specifically, you need these files (you need more than <em>just</em> these files to compile, obviously, but these are the ones that aren&rsquo;t included):</p>
<ul>
<li><code>/usr/include/netinet/ip.h</code></li>
<li><code>/usr/include/netinet/in_systm.h</code></li>
<li><code>/usr/include/netinet/ip_icmp.h</code></li>
<li><code>/usr/include/netinet/ip_var.h</code></li>
</ul>
<p>So here&rsquo;s a quick Bash script that links the relevant files to your iPhone OS and iPhone Simulator SDKs:<br />
<code>
<pre>for path in /Developer/Platforms/iPhone*/Developer/SDKs/*; do
    for file in /usr/include/netinet/ip.h \
                /usr/include/netinet/in_systm.h \
                /usr/include/netinet/ip_icmp.h \
                /usr/include/netinet/ip_var.h; do
        if [ ! -f "${path}${file}" ]; then
            sudo ln "${file}" "${path}${file}"
        fi;
    done;
done</pre>
<p></code><br />
I&rsquo;ve spoken to an Apple engineer and confirmed that this is the best way to do it, as well as filed a bug, which I encourage <a href="http://bugreport.apple.com">you to do as well</a> if this annoys you.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.slaunchaman.com/2010/02/13/using-apples-simpleping-on-iphone-os/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cocoa Tutorial: Strip Non-Alphanumeric Characters from an NSString</title>
		<link>http://blog.slaunchaman.com/2009/11/01/cocoa-tutorial-strip-non-alphanumeric-characters-from-an-nsstring/</link>
		<comments>http://blog.slaunchaman.com/2009/11/01/cocoa-tutorial-strip-non-alphanumeric-characters-from-an-nsstring/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 16:36:46 +0000</pubDate>
		<dc:creator>Jeff Kelley</dc:creator>
				<category><![CDATA[Programming Tutorials]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Cocoa Touch]]></category>
		<category><![CDATA[convenience]]></category>
		<category><![CDATA[NSCharacterSet]]></category>
		<category><![CDATA[NSString]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://blog.slaunchaman.com/?p=192</guid>
		<description><![CDATA[Let’s say you have an NSString that contains both alphanumeric and non-alphanumeric characters and you want to strip the non-alphanumeric characters out of it. The hard way is to manually go through, character-by-character, and put the character in a new string if it matches certain criteria. But why do it the hard way?
Apple provides a [...]]]></description>
			<content:encoded><![CDATA[<p>Let’s say you have an NSString that contains both alphanumeric and non-alphanumeric characters and you want to strip the non-alphanumeric characters out of it. The hard way is to manually go through, character-by-character, and put the character in a new string if it matches certain criteria. But why do it the hard way?</p>
<p>Apple provides a class that we can use for this to great effect: <a title="NSCharacterSet Class Reference" href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSCharacterSet_Class/Reference/Reference.html"><code>NSCharacterSet</code></a>. We want alphanumeric characters, so we can create a character set of the characters we want using this method:</p>
<blockquote><p><code>NSCharacterSet *alphanumericSet = [ NSCharacterSet alphanumericCharacterSet ];</code></p></blockquote>
<p>Now we have a character set like we want. We just need a way to turn our string into a string that contains only those characters. Unfortunately, the closest thing in <code>NSString</code>’s implementation is the <code>-stringByTrimmingCharactersInSet:</code> method. But that seems to do the <em>opposite</em> of what we want. Fortunately <code>NSCharacterSet</code> has our back here. We can use the <code>-invertedSet</code> method. So here is our final code:</p>
<blockquote><p><code>NSString *beginningString = @"Some string with non-alphanumeric characters. !@#$%^&amp;*()";<br />
NSCharacterSet *nonalphanumericSet = [[ NSCharacterSet alphanumericCharacterSet ] invertedSet ];<br />
NSString *endingString = [ beginningString stringByTrimmingCharactersInSet:nonalphanumericSet ];</code></p></blockquote>
<p>In this example, <code>endingString</code> will be equal to “Somestringwithnonalphanumericcharacters”.</p>
<p><strong>UPDATE:</strong> As it turns out, this only works if the non-alphanumeric characters are at the beginning or end of the <code>NSString</code>. Whoops.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.slaunchaman.com/2009/11/01/cocoa-tutorial-strip-non-alphanumeric-characters-from-an-nsstring/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automatically get the latest Chromium snapshot with launchd</title>
		<link>http://blog.slaunchaman.com/2009/05/19/automatically-get-the-latest-chromium-snapshot-with-launchd/</link>
		<comments>http://blog.slaunchaman.com/2009/05/19/automatically-get-the-latest-chromium-snapshot-with-launchd/#comments</comments>
		<pubDate>Wed, 20 May 2009 04:24:08 +0000</pubDate>
		<dc:creator>Jeff Kelley</dc:creator>
				<category><![CDATA[Miscellania]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[Chromium]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[launchd]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[open-source]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://blog.slaunchaman.com/?p=183</guid>
		<description><![CDATA[I’ve been checking out the snapshots of Chromium recently, and they’re coming quicker than you can say “multithreaded web browser.” To facilitate always having the latest version, I wrote a quick LaunchAgent that takes care of it on Mac OS X. First, I have a script named ~/bin/chromiupdate:


#!/bin/bash

# Downloads the latest version of Chromium.

remove_working_dir()
{
  [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been checking out the <a href="http://build.chromium.org/buildbot/snapshots/sub-rel-mac">snapshots</a> of <a href="http://www.chromium.org">Chromium</a> recently, and they’re coming quicker than you can say “multithreaded web browser.” To facilitate always having the latest version, I wrote a quick LaunchAgent that takes care of it on Mac OS X. First, I have a script named <strong>~/bin/chromiupdate</strong>:<br />
<code><br />
<blockquote>
<pre>#!/bin/bash

# Downloads the latest version of Chromium.

remove_working_dir()
{
    rm -rf "${WORKING_DIR}"
    exit 0
}

USER_DIR=$(dscl . -read /Users/$(whoami) NFSHomeDirectory | awk '{ print $2 }')
USER_APP_DIR="${USER_DIR}/Applications"
CHROMIUM_DIR="${USER_APP_DIR}/Chromium.app"
LATEST_URL="http://build.chromium.org/buildbot/snapshots/sub-rel-mac/LATEST"
TMP_DIR="/private/tmp"
WORKING_DIR="${TMP_DIR}/.chromium_launchd"
URL_BEGIN="http://build.chromium.org/buildbot/snapshots/sub-rel-mac"

if [ ! -d "${CHROMIUM_DIR}" ]; then
    mkdir -p "${CHROMIUM_DIR}"
fi

INSTALLED_VERSION="$(defaults read "${CHROMIUM_DIR}/Contents/Info" SVNRevision)"
VERSION=$(curl "${LATEST_URL}")

if [ "${VERSION}" != "${INSTALLED_VERSION}" ]; then
    logger Installed Chromium version \(${INSTALLED_VERSION}\) does not equal \
            latest version \(${VERSION}\), updating now...
    mkdir "${WORKING_DIR}" || exit 1
    trap remove_working_dir 1 2 3 6 15
    cd "${WORKING_DIR}" || exit 1
    curl -O "${URL_BEGIN}/${VERSION}/chrome-mac.zip"
    unzip chrome-mac.zip
    rsync -HavP --exclude="Contents/MacOS/chrome_debug.log" \
          "${WORKING_DIR}/chrome-mac/Chromium.app/" "${CHROMIUM_DIR}/"

    if [ "$(ps -aef | grep -i chromium | grep -v grep)" != "" ]; then
        open "${USER_DIR}/Library/Scripts/Chromium Update Dialog.app"
    fi

    logger "Chromium update complete. Version ${VERSION} installed."

    remove_working_dir
else
    logger Installed Chromium version \(${INSTALLED_VERSION}\) is up-to-date. \
           No action needed.
fi

exit 0</pre>
</blockquote>
<p></code><br />
Next, I have a property list named <strong>~/Library/LaunchAgents/com.slaunchaman.chromium.plist</strong>:<br />
<code><br />
<blockquote>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd &gt;
&lt;plist version="1.0"&gt;
    &lt;dict&gt;
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;com.slaunchaman.chromium&lt;/string&gt;
        &lt;key&gt;Program&lt;/key&gt;
        &lt;string&gt;/Users/slauncha/bin/chromiupdate&lt;/string&gt;
        &lt;key&gt;KeepAlive&lt;/key&gt;
        &lt;false/&gt;
        &lt;key&gt;StartInterval&lt;/key&gt;
        &lt;integer&gt;3600&lt;/integer&gt;
        &lt;key&gt;RunAtLoad&lt;/key&gt;
        &lt;true/&gt;
        &lt;key&gt;StandardOutPath&lt;/key&gt;
        &lt;string&gt;/dev/null&lt;/string&gt;
        &lt;key&gt;StandardErrorPath&lt;/key&gt;
        &lt;string&gt;/dev/null&lt;/string&gt;
    &lt;/dict&gt;
&lt;/plist&gt;</pre>
</blockquote>
<p></code></p>
<p>Finally, I have an AppleScript at <strong>~/Library/Scripts/Chromium Update Dialog.app</strong>:<br />
<code><br />
<blockquote>
<pre>display dialog "Chromium was just updated. You should restart it."</pre>
</blockquote>
<p></code></p>
<p>The LaunchAgent runs once an hour, checking to see if the installed version of Chromium is older than the latest snapshot. If so, it downloads it and uses <strong>rsync</strong> to copy the changes. The script places Chromium in <strong>~/Applications</strong>, but it shouldn’t be hard to modify to put it into /Applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.slaunchaman.com/2009/05/19/automatically-get-the-latest-chromium-snapshot-with-launchd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Take Me Home 1.1.1 Released</title>
		<link>http://blog.slaunchaman.com/2009/01/22/take-me-home-111-released/</link>
		<comments>http://blog.slaunchaman.com/2009/01/22/take-me-home-111-released/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 21:39:55 +0000</pubDate>
		<dc:creator>Jeff Kelley</dc:creator>
				<category><![CDATA[My Software]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[Take Me Home]]></category>

		<guid isPermaLink="false">http://blog.slaunchaman.com/?p=181</guid>
		<description><![CDATA[Take Me Home version number 1.1.1 is now available via iTunes.  This release has the following features:
-Tweaked UI
-Progress bar now updates more accurately
-Current location accuracy now displayed to user
Take Me Home version 1.1.1 is a free update to all Take Me Home owners.
]]></description>
			<content:encoded><![CDATA[<p><a title="Take Me Home" href="http://blog.slaunchaman.com/take-me-home">Take Me Home</a> version number 1.1.1 is now <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=296431880&amp;mt=8">available via iTunes</a>.  This release has the following features:</p>
<blockquote><p>-Tweaked UI<br />
-Progress bar now updates more accurately<br />
-Current location accuracy now displayed to user</p></blockquote>
<p>Take Me Home version 1.1.1 is a free update to all Take Me Home owners.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.slaunchaman.com/2009/01/22/take-me-home-111-released/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cocoa Touch Tutorial: Extract Address Book Address Values on iPhone OS</title>
		<link>http://blog.slaunchaman.com/2009/01/21/cocoa-touch-tutorial-extract-address-book-address-values-on-iphone-os/</link>
		<comments>http://blog.slaunchaman.com/2009/01/21/cocoa-touch-tutorial-extract-address-book-address-values-on-iphone-os/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 21:07:52 +0000</pubDate>
		<dc:creator>Jeff Kelley</dc:creator>
				<category><![CDATA[Programming Tutorials]]></category>
		<category><![CDATA[Address Book]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa Touch]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://blog.slaunchaman.com/?p=164</guid>
		<description><![CDATA[This is the first of what I hope to be several Cocoa Touch tutorials on this site.  I was doing some furious Googling last night trying to find out how to get a contact’s street address from the Address Book for an upcoming update to Take Me Home, and I realized that it’s complicated and [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first of what I hope to be several Cocoa Touch tutorials on this site.  I was doing some furious Googling last night trying to find out how to get a contact’s street address from the Address Book for an upcoming update to <a title="Take Me Home" href="http://blog.slaunchaman.com/take-me-home">Take Me Home</a>, and I realized that it’s complicated and there aren’t any good tutorials online.  So, after I figured it out, I commented it up so that hopefully, if you’re reading this, you’ll save some time that I didn’t.</p>
<p>Before you read this tutorial, you should go through Apple’s excellent <a title="Address Book Programming Guide for iPhone OS" href="http://developer.apple.com/iphone/library/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/">Address Book Programming Guide for iPhone OS</a>.  This tutorial will rely on the QuickStart application you write in the guide, so do that first.<br />
The first thing we need to do is add an address field to the QuickStart application.  Use Interface Builder to add a new UILabel underneath the two you already have.  You may want to stretch it to fill the entire width of the screen, like so:</p>
<div id="attachment_165" class="wp-caption aligncenter" style="width: 410px"><img class="size-full wp-image-165" title="Address Label" src="http://blog.slaunchaman.com/wp-content/uploads/2009/01/picture-1.png" alt="Add a new UILabel underneath the exisiting two." width="400" height="582" /><p class="wp-caption-text">Add a new UILabel underneath the exisiting two.</p></div>
<p>Now, add the information about this label to <strong>QuickStartViewController.h</strong>:</p>
<blockquote><p><code> </code></p>
<pre>//
//  QuickStartViewController.h
//  QuickStart
//

#import &lt;UIKit/UIKit.h&gt;
#import &lt;AddressBook/AddressBook.h&gt;
#import &lt;AddressBookUI/AddressBookUI.h&gt;

@interface QuickStartViewController : UIViewController &lt;ABPeoplePickerNavigationControllerDelegate&gt; {
    IBOutlet UILabel *firstName;
    IBOutlet UILabel *lastName;
    <strong>IBOutlet UILabel *addressLabel;</strong>
}

@property (nonatomic, retain) UILabel *firstName;
@property (nonatomic, retain) UILabel *lastName;
<strong>@property (nonatomic, retain) UILabel *addressLabel;</strong>

- (IBAction)showPicker:(id)sender;

@end</pre>
</blockquote>
<p>Be sure to go back into Interface Builder and connect File’s Owner in <strong>QuickStartViewController.xib</strong> to addressLabel.</p>
<p>Now, we have to change the method that gets called when you click on a person in the <em>ABPeoplePicker</em>.  As it is at the end of the QuickStart tutorial, once you select a person the picker is dismissed.  So, we do the following in <strong>QuickStartViewController.m</strong>:</p>
<blockquote><p><code> </code></p>
<pre>- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
      shouldContinueAfterSelectingPerson:(ABRecordRef)person {
    NSString *name = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
    self.firstName.text = name;
    [name release];

    name = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
    self.lastName.text = name;
    [name release];

    <del>[self dissmissModalViewControllerAnimated:YES];</del>

<strong>    return YES;</strong>
}</pre>
</blockquote>
<p>Note that you have to delete the line that dismisses the modal view controller; if you don’t, the people picker is dismissed before you have a chance to get the address.  When you delete it, the people picker will continue when you select a person.  Next up, we have to write the method for when someone selects an address on the next screen.  Here’s the method:</p>
<blockquote><p><code> </code></p>
<pre>- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
      shouldContinueAfterSelectingPerson:(ABRecordRef)person
                                property:(ABPropertyID)property
                              identifier:(ABMultiValueIdentifier)identifier {
    <strong>// Only inspect the value if it's an address.
    if (property == kABPersonAddressProperty) {
        /*
         * Set up an ABMultiValue to hold the address values; copy from address
         * book record.
         */
        ABMultiValueRef multi = ABRecordCopyValue(person, property);

        // Set up an NSArray and copy the values in.
        NSArray *theArray = [(id)ABMultiValueCopyArrayOfAllValues(multi) autorelease];

        // Figure out which values we want and store the index.
        const NSUInteger theIndex = ABMultiValueGetIndexForIdentifier(multi, identifier);

        // Set up an NSDictionary to hold the contents of the array.
        NSDictionary *theDict = [theArray objectAtIndex:theIndex];

        // Set up NSStrings to hold keys and values.  First, how many are there?
        const NSUInteger theCount = [theDict count];
        NSString *keys[theCount];
        NSString *values[theCount];

        // Get the keys and values from the CFDictionary.  Note that because
        // we're using the "GetKeysAndValues" function, you don't need to
        // release keys or values.  It's the "Get Rule" and only applies to
        // CoreFoundation objects.
        [theDict getObjects:values andKeys:keys];

        // Set the address label's text.
        NSString *address;
        address = [NSString stringWithFormat:@"%@, %@, %@, %@ %@",
                   [theDict objectForKey:(NSString *)kABPersonAddressStreetKey],
                   [theDict objectForKey:(NSString *)kABPersonAddressCityKey],
                   [theDict objectForKey:(NSString *)kABPersonAddressStateKey],
                   [theDict objectForKey:(NSString *)kABPersonAddressZIPKey],
                   [theDict objectForKey:(NSString *)kABPersonAddressCountryKey]];

        self.addressLabel.text = address;

        // Memory management.
        [theDict release];

        // Return to the main view controller.
        [ self dismissModalViewControllerAnimated:YES ];
        return NO;
    }

    // If they didn't pick an address, return YES here to keep going.
    return YES;
}</strong></pre>
<p><strong></strong></p></blockquote>
<p>Let’s go through that in more detail.  The method gives us the following information: an <em>ABRecordRef</em> of the person we’ve selected, an <em>ABPropertyID</em> of the property slected (in this case, we ensure that it’s the address) and an <em>ABMultiValueIdentifier</em> of which address we’ve selected.  It is important to note that the <em>ABPropertyID</em> is equal to <em>kABPersonAddressProperty</em> when you select any address; that is, there is only one address property.  This one address property holds the values in an <em>ABMultiValue</em>, each at a specific index.  Here are the steps we take in the code:</p>
<ol>
<li>The first thing we do is define our <em>ABMultiValue</em>, multi, and copy the contents of the selected value into it.</li>
<li>Then we define an <em>NSArray</em>, <strong>theArray</strong>, into which to copy the multiple values.  But which one do we want?</li>
<li>Each address has an identifier, which the method gives to us as identifier, but we reference them by index when getting them out of the array.  So, we need to create an index (which we’ll store as an unsigned integer), <strong>theIndex</strong>, and set it to the return value of the <code>ABMultiValueGetIndexForIdentifier</code> function.  Now that we have the index, we know which value of the array to store .  They’re stored as type <em>CFDictionary</em>, which have key-value pairs for us to use, so we define an <em>NSDictionary</em>, <strong>theDict</strong> to put them into.</li>
<li>First, we need to know how many key-value pairs there are, so we use the <code>count</code> method and store the return value in an unsigned integer, <strong>theCount</strong>.  Be sure that this variable doesn&amp;rquo;t change—you don’t want to assume that there are more members in the array than there actually are, as that can lead to nasty memory problems.  For that reason I’ve defined it as a constant.</li>
<li>Now, we define two <em>NSString</em> arrays, <strong>keys[theCount]</strong> and <strong>values[theCount]</strong>, and then we’re ready for action.</li>
<li>Next we use the <em>NSDictionary</em> <code>getObjects: andKeys:</code> function to copy the keys and values. The function copies the data, and we can construct our street address.  For the purpose of this example, I’m going to make the address a single line, but you do with it what you want.</li>
<li>Finally, we create a final <em>NSString</em> to put the formatted address into, pull the values out of the dictionary into the appropriate place, and we’re all done!</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.slaunchaman.com/2009/01/21/cocoa-touch-tutorial-extract-address-book-address-values-on-iphone-os/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Take Me Home 1.1.1 Sent to App Store</title>
		<link>http://blog.slaunchaman.com/2009/01/19/take-me-home-111-sent-to-app-store/</link>
		<comments>http://blog.slaunchaman.com/2009/01/19/take-me-home-111-sent-to-app-store/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 16:13:53 +0000</pubDate>
		<dc:creator>Jeff Kelley</dc:creator>
				<category><![CDATA[My Software]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[Take Me Home]]></category>

		<guid isPermaLink="false">http://blog.slaunchaman.com/?p=172</guid>
		<description><![CDATA[I’ve just sent in version 1.1.1 of Take Me Home.  It’s a minor fix with the following updates:
-Tweaked UI
-Progress bar now updates more accurately
-Current location accuracy now displayed to user
You can see a screenshot at the Take Me Home page and, as always, you can download the application via iTunes.
]]></description>
			<content:encoded><![CDATA[<p>I’ve just sent in version 1.1.1 of Take Me Home.  It’s a minor fix with the following updates:</p>
<blockquote><p>-Tweaked UI<br />
-Progress bar now updates more accurately<br />
-Current location accuracy now displayed to user</p></blockquote>
<p>You can see a screenshot at the <a title="Take Me Home" href="http://blog.slaunchaman.com/take-me-home">Take Me Home page</a> and, as always, you can <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=296431880&amp;mt=8">download the application via iTunes</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.slaunchaman.com/2009/01/19/take-me-home-111-sent-to-app-store/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Take Me Home 1.0.1 Released</title>
		<link>http://blog.slaunchaman.com/2008/12/31/take-me-home-101-released/</link>
		<comments>http://blog.slaunchaman.com/2008/12/31/take-me-home-101-released/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 23:30:24 +0000</pubDate>
		<dc:creator>Jeff Kelley</dc:creator>
				<category><![CDATA[My Software]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[Take Me Home]]></category>

		<guid isPermaLink="false">http://blog.slaunchaman.com/?p=159</guid>
		<description><![CDATA[Well, due to an App Store snafu, Take Me Home’s version number is wrong—1.0.1 instead of 1.1—but the new version is now available via iTunes. This release fixes problems people with the original iPhone and iPod Touch were having; there is now a progress bar that fills up as your iPhone has a better lock [...]]]></description>
			<content:encoded><![CDATA[<p>Well, due to an App Store snafu, <a title="Take Me Home" href="http://blog.slaunchaman.com/take-me-home">Take Me Home</a>’s version number is wrong—1.0.1 instead of 1.1—but the new version is now <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=296431880&amp;mt=8">available via iTunes</a>. This release fixes problems people with the original iPhone and iPod Touch were having; there is now a progress bar that fills up as your iPhone has a better lock on your current location.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.slaunchaman.com/2008/12/31/take-me-home-101-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
