<?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>Tiny Tim Games &#187; iPhone &amp; iPod touch</title>
	<atom:link href="http://www.tinytimgames.com/tag/iphone-ipod-touch/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tinytimgames.com</link>
	<description></description>
	<lastBuildDate>Sun, 18 Jul 2010 09:18:57 +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>Word Monkey updated to 1.2</title>
		<link>http://www.tinytimgames.com/2010/07/18/word-monkey-updated-to-1-2/</link>
		<comments>http://www.tinytimgames.com/2010/07/18/word-monkey-updated-to-1-2/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 09:18:57 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[News & Announcements]]></category>
		<category><![CDATA[Announcements]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone & iPod touch]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[Software Updates]]></category>
		<category><![CDATA[Word Monkey]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=577</guid>
		<description><![CDATA[A new Word Monkey update has just been approved by Apple! Version 1.2 includes support for iOS 4.0, including fast app switching. In addition, it fixes a few bugs that some users had reported. The update is available in the App Store now.]]></description>
			<content:encoded><![CDATA[<p>A new Word Monkey update has just been approved by Apple! Version 1.2 includes support for iOS 4.0, including fast app switching. In addition, it fixes a few bugs that some users had reported. The update is available in the App Store now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2010/07/18/word-monkey-updated-to-1-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Special Thank You</title>
		<link>http://www.tinytimgames.com/2010/07/04/a-special-thank-you/</link>
		<comments>http://www.tinytimgames.com/2010/07/04/a-special-thank-you/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 09:14:02 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[News & Announcements]]></category>
		<category><![CDATA[Announcements]]></category>
		<category><![CDATA[App Store]]></category>
		<category><![CDATA[Free Game of the Day]]></category>
		<category><![CDATA[iPhone & iPod touch]]></category>
		<category><![CDATA[OpenFeint]]></category>
		<category><![CDATA[Sale]]></category>
		<category><![CDATA[Sheepstacker]]></category>
		<category><![CDATA[Software Updates]]></category>
		<category><![CDATA[Word Monkey]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=571</guid>
		<description><![CDATA[We&#8217;d like to thank everyone who picked up Word Monkey during its time as OpenFeint&#8217;s Free Game of the Day! There are literally tens of thousands of new monkey trainers all over the world. As part of this &#8220;thank you&#8221;, we&#8217;d like to announce that not only have Sheepstacker and Sheepstacker Lite been updated for [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;d like to thank everyone who picked up <a title="Word Monkey" href="/games/wordmonkey" target="_blank">Word Monkey</a> during its time as OpenFeint&#8217;s <a title="Free Game of the Day" href="http://freegameoftheday.com" target="_blank">Free Game of the Day</a>! There are literally tens of thousands of new monkey trainers all over the world.</p>
<p>As part of this &#8220;thank you&#8221;, we&#8217;d like to announce that not only have Sheepstacker and Sheepstacker Lite been updated for iOS 4, but we&#8217;ve also given a NEW LOW PRICE to Sheepstacker! If you haven&#8217;t tried the game yet, now&#8217;s a great time to pick it up. You can <a title="Buy Sheepstacker NOW!" href="http://bit.ly/buy-sheepstacker" target="_blank">buy it from the App Store</a> or <a title="Try Sheepstacker NOW!" href="http://bit.ly/try-sheepstacker" target="_blank">try out the lite version</a> first.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2010/07/04/a-special-thank-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sheepstacker Update Fixes Scoring Issues</title>
		<link>http://www.tinytimgames.com/2010/04/29/sheepstacker-update-fixes-scoring-issues/</link>
		<comments>http://www.tinytimgames.com/2010/04/29/sheepstacker-update-fixes-scoring-issues/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 01:13:36 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[News & Announcements]]></category>
		<category><![CDATA[Announcements]]></category>
		<category><![CDATA[App Store]]></category>
		<category><![CDATA[High Scores]]></category>
		<category><![CDATA[iPhone & iPod touch]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[Sheepstacker]]></category>
		<category><![CDATA[Software Updates]]></category>
		<category><![CDATA[Support]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=541</guid>
		<description><![CDATA[Apple has just approved the 1.2.5 update of Sheepstacker. This update fixes the issue that users were having which caused high scores to not be recorded, either offline or online. The update should be available in the App Store shortly. We apologize for the inconvenience this issue caused our players. As always, our support link [...]]]></description>
			<content:encoded><![CDATA[<p>Apple has just approved the 1.2.5 update of Sheepstacker. This update fixes the issue that users were having which caused high scores to not be recorded, either offline or online. The update should be available in the App Store shortly.</p>
<p>We apologize for the inconvenience this issue caused our players. As always, our support link is available if you find you are having problems with one of our games. We will always give our best efforts to resolve any issues you may have with our games.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2010/04/29/sheepstacker-update-fixes-scoring-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Word Monkey, Sheepstacker Updates Available</title>
		<link>http://www.tinytimgames.com/2010/04/23/word-monkey-sheepstacker-updates-available/</link>
		<comments>http://www.tinytimgames.com/2010/04/23/word-monkey-sheepstacker-updates-available/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 21:56:39 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[News & Announcements]]></category>
		<category><![CDATA[Announcements]]></category>
		<category><![CDATA[App Store]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone & iPod touch]]></category>
		<category><![CDATA[Sheepstacker]]></category>
		<category><![CDATA[Software Updates]]></category>
		<category><![CDATA[Word Monkey]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=537</guid>
		<description><![CDATA[Word Monkey 1.1 has just been approved and should be available in the App Store shortly! Be sure to read up on all of the new features we&#8217;ve added to the game, including all-new iPad support. In addition to the Word Monkey update, Sheepstacker also received an update. The update fixes the freeze that would [...]]]></description>
			<content:encoded><![CDATA[<p>Word Monkey 1.1 has just been approved and should be available in the App Store shortly! Be sure to <a href="http://www.tinytimgames.com/2010/04/17/word-monkey-coming-to-ipad/" target="_self">read up</a> on all of the new features we&#8217;ve added to the game, including all-new iPad support.</p>
<p>In addition to the Word Monkey update, Sheepstacker also received an update. The update fixes the freeze that would occur on iPod touches when trying to access the Options menu, as well as a bug that would occur only on first run of the game. Be sure to grab this update, which should be available now.</p>
<p>UPDATE: We&#8217;ve been notified of a problem where new high scores are not recorded or uploaded to the high score server. We have fixed the issue and have already submitted the fix to Apple. We apologize profusely for the inconvenience this has caused our users!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2010/04/23/word-monkey-sheepstacker-updates-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Word Monkey Coming to iPad</title>
		<link>http://www.tinytimgames.com/2010/04/17/word-monkey-coming-to-ipad/</link>
		<comments>http://www.tinytimgames.com/2010/04/17/word-monkey-coming-to-ipad/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 09:12:02 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[News & Announcements]]></category>
		<category><![CDATA[Announcements]]></category>
		<category><![CDATA[App Store]]></category>
		<category><![CDATA[App Store Submissions]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone & iPod touch]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[Software Updates]]></category>
		<category><![CDATA[Word Monkey]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=523</guid>
		<description><![CDATA[Word Monkey is coming to iPad courtesy of a new update that has just been submitted to Apple! The new update makes Word Monkey a universal app that will run on iPhone, iPod touch, and iPad. Essentially, if you already have Word Monkey for your iPhone or iPod touch, you get the iPad version for [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-526" title="Word Monkey iPad split screen" src="http://www.tinytimgames.com/wp-content/uploads/2010/04/splitscreen.png" alt="" width="600" height="473" /></p>
<p>Word Monkey is coming to <a title="iPad" href="http://www.apple.com/ipad" target="_blank">iPad</a> courtesy of a new update that has just been submitted to Apple!</p>
<p>The new update makes Word Monkey a universal app that will run on iPhone, iPod touch, and iPad. Essentially, if you already have Word Monkey for your iPhone or iPod touch, you get the iPad version for free!</p>
<p>Here are some new features coming with the update:</p>
<ul>
<li>Play Word Monkey on the beautiful iPad screen with hi-res graphics.</li>
<li>Compete against a friend with the new split-screen multiplayer mode that&#8217;s only available for iPad.</li>
<li>Don&#8217;t have any good letters? Use two fingers to scroll the blocks upwards to get new letters quickly.</li>
</ul>
<p>Note that with the new iPad support, devices running OS 2.x will no longer be supported. You can upgrade your device to a newer version from iTunes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2010/04/17/word-monkey-coming-to-ipad/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Word Monkey 1.0.2 Now Available</title>
		<link>http://www.tinytimgames.com/2010/02/23/word-monkey-1-0-2-now-available/</link>
		<comments>http://www.tinytimgames.com/2010/02/23/word-monkey-1-0-2-now-available/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 23:22:29 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[News & Announcements]]></category>
		<category><![CDATA[Announcements]]></category>
		<category><![CDATA[App Store]]></category>
		<category><![CDATA[iPhone & iPod touch]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[Software Updates]]></category>
		<category><![CDATA[Word Monkey]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=514</guid>
		<description><![CDATA[An update for Word Monkey is now available in the App Store. This update has quite a few small changes, refinements and bug fixes. Most specifically, we tweaked one of the gameplay rules. Before, you couldn&#8217;t spell the same word twice in a single game session. The monkey would simply scratch his head, and the [...]]]></description>
			<content:encoded><![CDATA[<p>An update for <a title="Word Monkey Game Page" href="/games/wordmonkey" target="_blank">Word Monkey</a> is now available in the App Store. This update has quite a few small changes, refinements and bug fixes.</p>
<p>Most specifically, we tweaked one of the gameplay rules. Before, you couldn&#8217;t spell the same word twice in a single game session. The monkey would simply scratch his head, and the letters would stay on the screen. We realized this was confusing to some players (&#8220;Did I not spell the word right?&#8221; or &#8220;Is that word not recognized by the game?&#8221;). Now, the letters will disappear, but you won&#8217;t get points for a word that has already been spelled during a session.</p>
<p>In addition, we&#8217;ve added the &#8220;Smartest Monkeys&#8221; leaderboard in OpenFeint, so now you can see how your monkey stacks up to others that are playing the game. If you feel you must, you can also &#8220;Reset&#8221; your monkey and start all over again, though that would be a very mean thing to do to your monkey.</p>
<p>We clarified some of the instructions in the Dr. Schmachter intros, fixed a few bugs, and even improved performance on first generation devices. So make sure you grab the update from iTunes or in the App Store on your device. And if you don&#8217;t have the game yet, you can grab it <a title="BUY Word Monkey now!" href="http://bit.ly/buy-wordmonkey" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2010/02/23/word-monkey-1-0-2-now-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Word Monkey Available In The App Store!</title>
		<link>http://www.tinytimgames.com/2010/02/18/word-monkey-available-in-the-app-store/</link>
		<comments>http://www.tinytimgames.com/2010/02/18/word-monkey-available-in-the-app-store/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 00:28:27 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[News & Announcements]]></category>
		<category><![CDATA[Announcements]]></category>
		<category><![CDATA[App Store]]></category>
		<category><![CDATA[iPhone & iPod touch]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[Word Monkey]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=508</guid>
		<description><![CDATA[Word Monkey is now available in the App Store here! You can view more information about the game at the Word Monkey Game Page.]]></description>
			<content:encoded><![CDATA[<p><a style="text-decoration: none;" href="http://bit.ly/buy-wordmonkey"><img class="aligncenter size-full wp-image-511" title="Word Monkey Banner" src="http://www.tinytimgames.com/wp-content/uploads/2010/02/wordmonkey-banner.png" alt="" width="600" height="181" /></a></p>
<p>Word Monkey is now available in the App Store <a title="BUY Word Monkey now!" href="http://bit.ly/buy-wordmonkey" target="_blank">here</a>! You can view more information about the game at the <a title="Word Monkey Game Page" href="/games/wordmonkey" target="_self">Word Monkey Game Page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2010/02/18/word-monkey-available-in-the-app-store/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coming Soon: &#8220;Word Monkey&#8221;</title>
		<link>http://www.tinytimgames.com/2010/02/12/coming-soon-word-monkey/</link>
		<comments>http://www.tinytimgames.com/2010/02/12/coming-soon-word-monkey/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 23:55:25 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[News & Announcements]]></category>
		<category><![CDATA[Announcements]]></category>
		<category><![CDATA[App Store]]></category>
		<category><![CDATA[App Store Submissions]]></category>
		<category><![CDATA[iPhone & iPod touch]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Word Monkey]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=478</guid>
		<description><![CDATA[It&#8217;s been a long time coming, but our new game Word Monkey for iPhone &#38; iPod touch has been submitted to Apple and should be available soon! In Word Monkey, your goal as Dr. Schmachter&#8217;s lab assistant is to use your device to train a cute little lab monkey by programming words directly into its [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tinytimgames.com/wp-content/uploads/2010/02/wordmonkey-promo.png"><img class="aligncenter size-full wp-image-487" title="Word Monkey Promo" src="http://www.tinytimgames.com/wp-content/uploads/2010/02/wordmonkey-promo.png" alt="" width="550" height="400" /></a></p>
<p>It&#8217;s been a long time coming, but our new game <strong><a title="Word Monkey Game Page" href="/games/wordmonkey" target="_self">Word Monkey</a></strong> for iPhone &amp; iPod touch has been submitted to Apple and should be available soon!</p>
<p>In Word Monkey, your goal as Dr. Schmachter&#8217;s lab assistant is to use your device to train a cute little lab monkey by programming words directly into its brain! You have to quickly spell words from the rising jumble of letters before they hit the top of the screen, or it&#8217;s game over.</p>
<p>Head over to the <a title="Word Monkey Game Page" href="/games/wordmonkey" target="_self">Word Monkey game page</a> to find out more information about the game. There you&#8217;ll find screenshots of the game, and we&#8217;ll be posting some video of the game over the next few days.</p>
<p>We&#8217;ll post again when the game has been approved and is up on the App Store!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2010/02/12/coming-soon-word-monkey/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Unity/Objective-C Divide</title>
		<link>http://www.tinytimgames.com/2010/01/10/the-unityobjective-c-divide/</link>
		<comments>http://www.tinytimgames.com/2010/01/10/the-unityobjective-c-divide/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 12:15:37 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[iPhone & iPod touch]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Unity]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=389</guid>
		<description><![CDATA[UPDATE: There was a typo in the code section that adds the observer for NSUserDefaults. This has now been corrected. I also added information about how to find the proper assembly file when trying to access script class methods. WARNING: The following is a technical article. Don&#8217;t blame me if you find it boring! I [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATE: There was a typo in the code section that adds the observer for <em>NSUserDefaults</em>. This has now been corrected. I also added information about how to find the proper assembly file when trying to access script class methods.</p>
<p>WARNING: The following is a technical article. Don&#8217;t blame me if you find it boring!</p>
<p>I love <a title="Unity" href="http://www.unity3d.com" target="_self">Unity</a>! The Unity iPhone engine is a fantastic piece of technology, allowing us to quickly develop games without having to worry about a lot of the underlying stuff. However, Unity is essentially an additional layer on top of the iPhone SDK, which means that while the iPhone SDK may advance with new features, the Unity engine is generally a step behind with adding these features in a manner that can be easily accessed through script.</p>
<p>Enter Objective-C: This is the language that iPhone apps are usually written in. Unity provides some support for calling native Objective-C code from Unity script, but only for Advanced licensees and only in one direction. This can be pretty limiting especially if you&#8217;re trying to use a lot of the fancy features in iPhone OS 3.0. Sure, you can pass around information using the <em>PlayerPrefs</em> trick. But this has the problem of not being instantaneous, and it forces the app to constantly poll for new commands, which probably isn&#8217;t a good idea performance-wise.</p>
<p>What follows is a method for immediately calling Objective-C code from Unity script (for both Basic and Advanced licenses) and also vice versa! That&#8217;s right, two-way communication between Objective-C and Unity script that&#8217;s instantaneous.</p>
<p><span id="more-389"></span><strong>Unity to Objective-C (for Advanced licensees)</strong></p>
<p>First, for the Advanced license users of Unity, you already have a quick and easy way of calling Objective-C code from Unity script. In C#, just do the following:</p>
<pre>[System.Runtime.InteropServices.DllImport("__Internal")]
extern static public int AwesomeFunction(int awesomeParameter);</pre>
<p>Then, in a C/C++/Objective-C file somewhere in your Unity-built Xcode project, do the following:</p>
<pre>int AwesomeFunction(int awesomeParameter)
{
   // My awesome code goes here.

  return somethingAwesome;
}</pre>
<p>You may have to wrap your function prototypes in <em>extern &#8220;C&#8221; { &#8230; }</em> if you&#8217;re using C++/Objective-C++ due to name mangling.</p>
<p><strong>Unity to Objective-C (for Basic licensees)</strong></p>
<p>Now for you Basic license users, you&#8217;ve been used to sending a command to Objective-C from Unity script like this:</p>
<pre>PlayerPrefs.SetString("Commands",
   String.Format("AwesomeCommand|{0}|{1}", awesome1, awesome2));</pre>
<p>Or something similar. You&#8217;ll still be sending commands this way. However, in Objective-C, you probably have an <em>NSTimer</em> that is constantly polling to see if the &#8220;Commands&#8221; key in <em>NSUserDefaults</em> has a string in it. You might even have some fancy queueing system set up so that you can call multiple commands in a row without them overwriting each other. The issue, though, is that if you need a result back from one of these commands, you can&#8217;t get it instantaneously. You have to set up some kind of polling system in Unity script to wait for a return result to show up in some other <em>PlayerPrefs</em> key. Messy.</p>
<p>But there&#8217;s a better way. Let me introduce you to Key-Value Observing. The iPhone SDK provides a method for setting up &#8220;observers&#8221; for certain things currently going on in the system. It just so happens that one of the things that you can &#8220;observe&#8221; is <em>NSUserDefaults</em>. That&#8217;s our ticket!</p>
<p>Somewhere in your Objective-C code (where you might normally set up the <em>NSTimer</em> for polling the <em>NSUserDefaults</em>), place the following code:</p>
<pre>[[NSUserDefaults standardUserDefaults] addObserver:self
   forKeyPath:@"Command" options:0 context:nil];</pre>
<p>Then, create a method like the following:</p>
<pre>- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
   change:(NSDictionary *)change context:(void *)context
{
   // Command parsing code goes here.
}</pre>
<p>The <em>observeValueForKeyPath</em> method is essentially the function you had before that parsed the commands from <em>PlayerPrefs</em>/<em>NSUserDefaults</em>. What the <em>addObserver</em> moethod does is set <em>self</em> to be an observer of <em>NSUserDefaults</em>, meaning that every time you set the <em>PlayerPrefs</em> in Unity script, the <em>observeValueForKeyPath</em> method gets called <strong>immediately!</strong></p>
<p>What this now allows you to do is to set a result key in Objective-C and immediately access it in Unity script. Here&#8217;s an example:</p>
<pre>// Objective-C code
if([[[NSUserDefaults standardUserDefaults] getObjectForKey:@"Command"]
   isEqualToString:@"DoSomething")
{
   // Return a result by setting the key here.
   [[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"Result"];
}</pre>
<pre>// Unity C# code
int CallDoSomething()
{
   PlayerPrefs.SetString("Command", "DoSomething");
   // Before, doing something like this would be very bad!
   return PlayerPrefs.GetInt("Result");
}</pre>
<p>As you can see, you can get immediate results from the Objective-C code! Hooray!</p>
<p><strong>Objective-C to Unity (for everyone)</strong></p>
<p>Where Advanced and Basic licensees meet is in the need for having Objective-C code call back to Unity script. There are many instances where you need to capture an event in Objective-C and then pass this off immediately to your Unity scripts so that you can update your game. While using <em>NSUserDefaults</em> to send information back to <em>PlayerPrefs</em> is certainly doable, a polling system would need to be set up in Unity script and it would never be instantaneous.</p>
<p>To get this working, you need to know a little bit about the underlying Unity frameworks. Unity uses a framework called Mono, which is an open-source cross-platform implementation of .NET. When you use something in the System namespace or String.Format, you&#8217;re actually using .NET libraries, and not something Unity-specific. While the actual invocation of the Mono runtime isn&#8217;t visible from inside the Xcode project, that doesn&#8217;t mean we can&#8217;t still have access to the Mono functions.</p>
<p>You can do amazing things with C. You can also do terrible things with C. That&#8217;s why it&#8217;s preferred by so many programmers, as data and memory in C is completely malleable. You can do almost anything with it. Even though we don&#8217;t have access to the Mono header files in the Unity Xcode project, by doing some handy Internet searches, we can get the function prototypes of all of the Mono functions we&#8217;ll need to get what we want.</p>
<p>In addition, many Mono functions require or return special MonoTypes. This would be a problem in C#, but in C a void pointer cures all! For our purposes, here are all of the MonoTypes that we need:</p>
<pre>typedef void* MonoDomain;
typedef void* MonoAssembly;
typedef void* MonoImage;
typedef void* MonoClass;
typedef void* MonoObject;
typedef void* MonoMethodDesc;
typedef void* MonoMethod;
typedef int gboolean;</pre>
<p>To be honest, you don&#8217;t even really have to set up the typedefs, but it makes the function prototypes look cleaner and more readable. Remember, since pointers simply point to memory, they don&#8217;t really need a type.</p>
<p>Now for the function prototypes that we&#8217;ll need. The following is the bare minimum of functions needed to accomplish calling Unity script code from Objective-C. (Remember: You may need to wrap these in <em>extern &#8220;C&#8221; { &#8230; }</em> if you&#8217;re using C++/Objective-C++ due to name mangling.)</p>
<pre>MonoDomain *mono_domain_get();
MonoAssembly *mono_domain_assembly_open(MonoDomain *domain, const char *assemblyName);
MonoImage *mono_assembly_get_image(MonoAssembly *assembly);
MonoMethodDesc *mono_method_desc_new(const char *methodString, gboolean useNamespace);
MonoMethodDesc *mono_method_desc_free(MonoMethodDesc *desc);
MonoMethod *mono_method_desc_search_in_image(MonoMethodDesc *methodDesc, MonoImage *image);
MonoObject *mono_runtime_invoke(MonoMethod *method, void *obj, void **params, MonoObject **exc);</pre>
<p>Here&#8217;s where we need to explain things: We call Unity script functions by using the <em>mono_runtime_invoke</em> function. However, before we can call this, we need to get the <em>MonoMethod</em> (essentially, the pointer to the Unity script function we want to call) from the assembly file that was compiled by Unity when you hit &#8220;Build &amp; Run&#8221;. So how do we get that?</p>
<p>First things first, we need to get the domain where all of the Unity scripts are running. In the vaguest of terms, a domain is kind of a box where scripts are run. So we need to grab the Mono domain first:</p>
<pre>MonoDomain *domain = mono_domain_get();</pre>
<p>Simple enough. We now have the location where all of the Unity scripts are being run. Now to get the MonoMethod, we first need to get a reference to the assembly that contains the function. In your Xcode project, if you look in the Libraries group, you&#8217;ll see a bunch of &#8216;dll.s&#8217; files. These files get compiled by Xcode on Build into DLL files that get placed into your app&#8217;s <em>Data</em> folder. If you don&#8217;t believe me, take your built Unity app, Show Package Contents on it, and then browse around.</p>
<p>Knowing the folder structure of the built application is actually important to this process, as we&#8217;re going to be directly referencing these DLLs for the next step. We need to get the assembly itself so we can read through it and find our functions. Here&#8217;s how to do that:</p>
<pre>NSString *assemblyPath = [[[NSBundle mainBundle] bundlePath]
   stringByAppendingPathComponent:@"Data/Assembly - CSharp.dll"]
MonoAssembly *assembly = mono_domain_assembly_open(domain, path.UTF8String);
MonoImage *image = mono_assembly_get_image(assembly);</pre>
<p>You&#8217;ll notice we put in the path of the built DLL file from the application&#8217;s main bundle. Note that the assembly you&#8217;re looking for might be different for the class method you&#8217;re trying to access. To find out the correct assembly, highlight the script in Unity and go into Debug mode in the Inspector. The Assembly Identifier should tell you the name of the assembly. We then get the assembly from our domain. The MonoImage is something we&#8217;ll need for the next step.</p>
<p>We have our assembly now, and we can start accessing the functions inside it. To do this, we need to tell Mono what functions we&#8217;re looking for. (For ease of use, I&#8217;m only going to be looking for static methods in classes without a namespace. If you want to access specific objects or call non-static methods, I suggest you read up on the official documentation on <a title="Embedding Mono" href="http://www.mono-project.com/Embedding_Mono" target="_blank">Embedding Mono</a>.)</p>
<pre>MonoMethodDesc *desc = mono_method_desc_new("AwesomeClass:AwesomeFunction()", FALSE);
MonoMethod *method = mono_method_desc_search_in_image(desc, image);
mono_method_desc_free(desc);</pre>
<p>Notice that the <em>MonoMethodDesc</em> (literally, MonoMethod Description) is created by giving <em>mono_method_desc_new</em> a string that contains the method that we want to call. Remember to put the class name before the function and follow it with a <strong>colon</strong>, not a period. If you want to access a method with parameters, do something like this:</p>
<pre>"AwesomeClass:AwesomerFunction(int,int,int)"</pre>
<p>Formatting is very important. There shouldn&#8217;t be any spaces between the method parameters. After getting the description, we then search the assembly image for the method. Doing all of this searching could impact performance in your app, so it&#8217;s recommended that you do all of this in an initialization function and store the pointers to the various <em>MonoMethods</em> you want to use. After we have the method pointer, we free the <em>MonoMethodDesc</em> that was created.</p>
<p>Now you have your <em>MonoMethod</em>! And you say you want to call it! We can do that very easily now:</p>
<pre>mono_runtime_invoke(method, NULL, NULL, NULL);</pre>
<p>See? Very simple. If your method had some parameters in it, you need to pass the arguments as a void pointer array to the third parameter of <em>mono_runtime_invoke</em>, like so:</p>
<pre>int param1 = 1;
int param2 = 27;
void *args[] = { &amp;param1, &amp;param2 };

mono_runtime_invoke(method, NULL, args, NULL);</pre>
<p>We are essentially passing the arguments by their address via way of an array.</p>
<p>And that&#8217;s it! There are a few caveats to using this method of invoking Unity script methods: Firstly, it&#8217;s slow. It would not be recommended to call these many times per frame or even once every frame. It&#8217;s primarily good for callbacks that occur every now and then (like for GameKit connection results, etc). Secondly, you&#8217;re putting a lot of trust in the Mono and Unity developers to not change things around too drastically. If you upgrade Unity and your code suddenly stops working, you&#8217;ll need to downgrade to the previous version of Unity or muck around until you can find out what was changed.</p>
<p><strong>Conclusion</strong></p>
<p>Finding all of this out was a long weekend project for me, and it has definitely been worth it. Functionality that I simply didn&#8217;t think was possible without official Unity support is now immediately available, and I am now able to bounce back and forth between Unity script and Objective-C to get access to whatever I need. There are performance issues to consider, but on the whole the flexibility outweighs the potential performance pitfalls. It just requires you to properly plan your app with these things in mind.</p>
<p>Some may read this article and think that the Advanced license is obsolete with these methods. However, I don&#8217;t think that&#8217;s true. The simple fact that Advanced users can use namespaces like <em>System.Runtime.InteropServices</em> and <em>System.Xml</em> are worth it alone, especially when you consider that you can&#8217;t send something as complex as a struct or class through a <em>PlayerPrefs</em> string (I guess you could, but it wouldn&#8217;t be very pretty). This is really just a stopgap measure to allow Basic license users access to some of the native functionality that isn&#8217;t available in Unity yet. The splash screen requirement alone was enough for us to upgrade!</p>
<p>In addition, using the Objective-C to Unity callback functionality is not for the faint of heart, and certainly not for those who aren&#8217;t well-versed in the art of programming. Just be sure to design your games around what you <strong>can</strong> do, not around what you <strong>wish</strong> you could do.</p>
<p>I hope you&#8217;ve found this both educational and useful and that you&#8217;ll consider contributing your own findings to the Unity community.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2010/01/10/the-unityobjective-c-divide/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Super Smoothie Available in the App Store!</title>
		<link>http://www.tinytimgames.com/2009/12/18/super-smoothie-available-in-the-app-store/</link>
		<comments>http://www.tinytimgames.com/2009/12/18/super-smoothie-available-in-the-app-store/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 05:23:50 +0000</pubDate>
		<dc:creator>Jerrod Putman</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[News & Announcements]]></category>
		<category><![CDATA[Announcements]]></category>
		<category><![CDATA[App Store]]></category>
		<category><![CDATA[Collaboration]]></category>
		<category><![CDATA[iPhone & iPod touch]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Super Smoothie]]></category>

		<guid isPermaLink="false">http://www.tinytimgames.com/?p=336</guid>
		<description><![CDATA[We would like to announce that Super Smoothie, a game by our good friends at GoPlay Games, is now available in the App Store! This is a special game for us as we helped the gang at GoPlay in the development of this fun and fruity matching game. Check out this gameplay video for Super [...]]]></description>
			<content:encoded><![CDATA[<p>We would like to announce that <strong>Super Smoothie</strong>, a game by our good friends at <a title="GoPlay Games" href="http://www.goplaygames.net" target="_blank">GoPlay Games</a>, is now available in the App Store! This is a special game for us as we helped the gang at GoPlay in the development of this fun and fruity matching game.</p>
<p>Check out this gameplay video for Super Smoothie:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="295" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/KU9eN-QdrYs&amp;hl=en_US&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="295" src="http://www.youtube.com/v/KU9eN-QdrYs&amp;hl=en_US&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Super Smoothie is available NOW in the App Store <a title="Buy Super Smoothie NOW in the App Store!" href="http://bit.ly/buy-supersmoothie" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinytimgames.com/2009/12/18/super-smoothie-available-in-the-app-store/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
