<?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>Josh Schumacher: A PHP Developer &#187; Objective-C</title>
	<atom:link href="http://blog.joshschumacher.com/category/objective-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.joshschumacher.com</link>
	<description>The biggest and the best in the Northwest</description>
	<lastBuildDate>Thu, 29 Oct 2009 21:54:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Reading Common and Custom Values From Your Info.plist</title>
		<link>http://blog.joshschumacher.com/2009/02/19/reading-common-and-custom-values-from-your-infoplist/</link>
		<comments>http://blog.joshschumacher.com/2009/02/19/reading-common-and-custom-values-from-your-infoplist/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 00:35:21 +0000</pubDate>
		<dc:creator>Josh Schumacher</dc:creator>
				<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[iPhone SDK]]></category>

		<guid isPermaLink="false">http://blog.joshschumacher.com/?p=20</guid>
		<description><![CDATA[It seems like a pretty simple, common thing you would want to do in objective-c right?  All applications have an Info.plist (or a different plist file as defined in your "Info.plist File" property of your build target).  I've been pretty frustrated with the quality of google search results when trying to figure out how to [...]]]></description>
			<content:encoded><![CDATA[<p>It seems like a pretty simple, common thing you would want to do in objective-c right?  All applications have an Info.plist (or a different plist file as defined in your "Info.plist File" property of your build target).  I've been pretty frustrated with the quality of google search results when trying to figure out how to do more or less mundane things with the iPhone SDK.  I'm going to start writting posts, especially when I have a hard time trying to find what I was looking for in search results.</p>
<p>Here's the quick and dirty: I have a game that we're building here at <a href="http://treemolabs.com">Treemo Labs</a>, <a href="http://www.ticatacgames.net">Tic A Tac Poker</a>.  We're working on getting a lite version out the door.  I wanted to read a custom value out of the Info.plist to tell if it's the lite version or not.  I couldn't figure out how to read a simple value from the default property list file.  Here's some sample code to get the bundleIdentifier, bundle version and custom values from your Info.plist</p>
<div class="igBar"><span id="lcode-2"><a href="#" onclick="javascript:showPlainTxt('code-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-2">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Create a new NSBundle pointer</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">NSBundle* mainBundle;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// The Info.plist is considered the mainBundle.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mainBundle = <span style="color:#006600; font-weight:bold;">&#91;</span>NSBundle mainBundle<span style="color:#006600; font-weight:bold;">&#93;</span>;&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Reads the value of the custom key I added to the Info.plist</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#91;</span>mainBundle objectForInfoDictionaryKey:@<span style="color:#CC0000;">"myCustomKey"</span><span style="color:#006600; font-weight:bold;">&#93;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Another handy thing I had to search around for a little</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Get the value for the &quot;Bundle version&quot; from the Info.plist</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#91;</span>mainBundle objectForInfoDictionaryKey:@<span style="color:#CC0000;">"CFBundleVersion"</span><span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Need the bundle identifier? (probably something like com.mycorp.product)</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#91;</span>mainBundle bundleIdentifier<span style="color:#006600; font-weight:bold;">&#93;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>For more information about the NSBundle, view the <a href="http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSBundle_Class/Reference/Reference.html#//apple_ref/doc/uid/20000214">NSBundle Reference Documentation</a>.</p>
<p>To see an alphabetical list of the standard keys you can use in an information property list file, along with a brief description and the platforms to which they apply (Mac OS X or iPhone) check out the <a href="http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html">Property List Key Reference</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.joshschumacher.com/2009/02/19/reading-common-and-custom-values-from-your-infoplist/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
