﻿<?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>Tonny Xu &#187; iPhone Dev</title>
	<atom:link href="http://www.totodotnet.net/category/blog/iphone-dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.totodotnet.net</link>
	<description>Life is like a box of chocolates...</description>
	<lastBuildDate>Thu, 01 Apr 2010 14:17:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Best Practice on Derive an iPhone project from existed project</title>
		<link>http://www.totodotnet.net/2009/10/06/best-practice-on-derive-an-iphone-project/</link>
		<comments>http://www.totodotnet.net/2009/10/06/best-practice-on-derive-an-iphone-project/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 19:40:17 +0000</pubDate>
		<dc:creator>tonny.xu</dc:creator>
				<category><![CDATA[iPhone Dev]]></category>
		<category><![CDATA[iph]]></category>

		<guid isPermaLink="false">http://www.totodotnet.net/?p=376</guid>
		<description><![CDATA[After I finished an iPhone project, I decided to create a similar project based on that one. So, I copied the previous project directory to an new directory and build it. Everything goes fine, the new project was correctly signed and installed on the machine, the icon and Default.png was correctly displayed.  But, only one [...]]]></description>
			<content:encoded><![CDATA[<p>After I finished an iPhone project, I decided to create a similar project based on that one. So, I copied the previous project directory to an new directory and build it. Everything goes fine, the new project was correctly signed and installed on the machine, the icon and Default.png was correctly displayed.  But, only one thing was out of my expectation.</p>
<p>I installed the debug version of the previous project on the simulator and want to compare the look and feel, but after I install the new project, which was derived from the old project, on the iPhone simulator, shit happened! <strong>The old project was <span style="color: #ff0000;">disappeared</span>!</strong> Only the new project was there. I checked the project setting over and over again and got no clue completely. This drove me mad! Was it because I did not rename the project? I simply copied to a new directly, without changing the project name. Nope, it wasn&#8217;t. Was it because I set the wrong Product Name? Nope, it was not. What made the iPhone thinks this 2 apps were the same?</p>
<p>After I googled and tried a lot, just before I want to give up, I suddenly saw a key in info.plist file. the key is &#8220;<span style="color: #0000ff;"><strong>Bundle Identifier</strong></span>&#8220;. Oh My GOD! It should be the reason! My instinct told me! I added some suffix to the identifier to make it unique, then try again on the simulator, <strong><span style="color: #0000ff;">it WORKED</span></strong>! It&#8217;s the reason!</p>
<p>Yes, iPhone Programming Guide told us every project need an unique identifier, thus Apple recommend us use the Java Package Style to identifier each app. But if you are copying project from here to there, you might miss this because without modify it, the app also worked fine. Dude&#8230;.</p>
<p>I hope this would help you if you are facing similar problem as me.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totodotnet.net/2009/10/06/best-practice-on-derive-an-iphone-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Best practice to protect your iPhone application from pirates</title>
		<link>http://www.totodotnet.net/2009/09/28/the-best-practice-to-protect-your-iphone-application-from-pirates/</link>
		<comments>http://www.totodotnet.net/2009/09/28/the-best-practice-to-protect-your-iphone-application-from-pirates/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 13:34:06 +0000</pubDate>
		<dc:creator>tonny.xu</dc:creator>
				<category><![CDATA[iPhone Dev]]></category>
		<category><![CDATA[anti-hack]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[info.plist]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.totodotnet.net/?p=333</guid>
		<description><![CDATA[iPhone app developers are facing their hard worked app appears on the pirate app web site the day after it appears on iTunes. So you must want to protect your app as I do, right? But how? What&#8217;s the best way to protect your apps?
Here is the best practice by far I know. And it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>iPhone app developers are facing their hard worked app appears on the pirate app web site the day after it appears on iTunes. So you must want to protect your app as I do, right? But how? What&#8217;s the best way to protect your apps?</p>
<p>Here is the best practice by far I know. And it&#8217;s really simple and easy to do with. As far as Doskoi know, every hacked iPhone app need to add a key to the info.plist file. They need to add this:</p>
<pre>SignerIdentity
Apple iPhone OS Application Signing</pre>
<p>So it would be easy for us to detect whether your app was pirated or not. Simply using the following code to protect your apps.</p>
<pre>
 NSBundle *bundle = [NSBundle mainBundle];
 NSDictionary *info = [bundle infoDictionary];
 if ([info objectForKey: @"SignerIdentity"] != nil)
 {
 // Add your anti-pirate code here.
 }
</pre>
<p>Hope it will help you.</p>
<p><a href="http://doskoi.cn/2009/08/how-to-protect-iphone-apps-cracks/">Doskoi’s Lounge » iPhone软件的破解保护</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totodotnet.net/2009/09/28/the-best-practice-to-protect-your-iphone-application-from-pirates/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Damn it, change the project name cost me a whole day!</title>
		<link>http://www.totodotnet.net/2009/08/14/damn-it-change-the-project-name-cost-me-a-whole-day/</link>
		<comments>http://www.totodotnet.net/2009/08/14/damn-it-change-the-project-name-cost-me-a-whole-day/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 02:44:45 +0000</pubDate>
		<dc:creator>tonny.xu</dc:creator>
				<category><![CDATA[iPhone Dev]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.totodotnet.net/2009/08/14/damn-it-change-the-project-name-cost-me-a-whole-day/</guid>
		<description><![CDATA[Yes, I knew, I am SO stupid, I should Google it before I started to change the XCode project name. It cost me a whole day! What a joke.
All right, if you are looking for the correct way to change your application&#8217;s name show on the iPhone main screen. You need follow my steps.

Scroll the [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, I knew, I am SO stupid, I should Google it before I started to change the XCode project name. It cost me a whole day! What a joke.</p>
<p>All right, if you are looking for the correct way to <strong>change your application&#8217;s name</strong> show on the iPhone main screen. You need follow my steps.</p>
<ol>
<li>Scroll the left “<strong>Groups &amp; Files</strong>” panel to the top(Where you put it, I putted it in the left.), and double-click your project name. This will lead us to step 2.</li>
<li>In the <strong>Build </strong>tab, find the <strong>configuration</strong> dropdown list, select “<strong>All configurations</strong>”(Usually, on the top), and then type “Product Name”(It’s not case sensitive, remember the space) in the search box next to the dropdown list.</li>
<li>Type whatever name you like in the right side field, and then close it and go to step 4.</li>
<li>Choose <strong>Build-&gt;Clean all targets</strong>, then rebuild your project, It’s done!</li>
</ol>
<p><strong>Remember</strong>! Do <strong>NOT</strong> change your target or add your own target! That’s the wrong way, and will cause code sign failure, and it’s hard to repair!</p>
<p>God, Damn you Apple, you should post a tutorial for the developer. Now I did it for you, and you <strong>should pay me</strong>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totodotnet.net/2009/08/14/damn-it-change-the-project-name-cost-me-a-whole-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;AAC&#8221; is &#8220;evil&#8221;</title>
		<link>http://www.totodotnet.net/2009/06/17/aac-is-evil/</link>
		<comments>http://www.totodotnet.net/2009/06/17/aac-is-evil/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 08:44:45 +0000</pubDate>
		<dc:creator>tonny.xu</dc:creator>
				<category><![CDATA[iPhone Dev]]></category>
		<category><![CDATA[CoreAudio]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[SystemSound]]></category>

		<guid isPermaLink="false">http://www.totodotnet.net/2009/06/17/aac-is-evil/</guid>
		<description><![CDATA[Problem
Few days ago, I wrote a post on which is the best audio format we should choose when developing an iPhone app. The conclusion is using IMA4, it’s the best choice if you want to record audio on the device.
Today, I was trying to use the System Sound service to play a short audio and [...]]]></description>
			<content:encoded><![CDATA[<h3>Problem</h3>
<p>Few days ago, I wrote a post on <a href="http://www.totodotnet.net/2009/05/14/best-audio-format-for-iphone-audio-programming/">which is the best audio format we should choose</a> when developing an iPhone app. The conclusion is using IMA4, it’s the best choice if you want to record audio on the device.</p>
<p>Today, I was trying to use the System Sound service to play a short audio and in order to save the spaces, I chose the “AAC” format to encode my sound effects. I just thought it’s would be capable for a system sound and didn’t searched the documentation for which format is suit for System Sound. Everything went fine in the simulator. But, when I load the app into the device, and, BOOM~~, it failed to play the sound effect! My first reaction was somewhere programmatic mistake in my code, and after a careful review, I thought the reason could&#160; be the format. So I changed the format back to IMA4, and this time, it went well!</p>
<p>Apparently, System sound did not support AAC format, and I could not find the appropriate document where described it. Apple just pushes us to use IMA4 and other linear PCM format to reduce the CPU and power consume. Yeah, I understand that, but please, place such kind of important information some where we can find it easily! The API documentation could be a good place.</p>
<p>If I am the director of the documentation team, I would promote such information and place it in a notable place! Damn it.</p>
<h3>Why I’m angry?</h3>
<p>Because if you using AAC for recording or System Sound, it works fine on the simulator, but will be failed on the device! If the device does not support AAC for recording and System Sound, <strong><font color="#ff0000">please disable it on the simulator!</font></strong></p>
<h3>Conclusion</h3>
<p>The conclusion is if you want to playback a song or something like this, you can choose AAC as your primary format for it is well supported by hardware codec, <strong>but only for this purpose please</strong>. If you want to record audio or play system sound effect, please choose IMA4, it’s is the second best format for iPhone.</p>
<p>“AAC” is a good compressed format, but it’s also has its cost. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.totodotnet.net/2009/06/17/aac-is-evil/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to enable autorotation when combining UITabBarController and UINavigationController and your own views</title>
		<link>http://www.totodotnet.net/2009/06/13/how-to-enable-autorotation-when-combining-uitabbarcontroller-and-uinavigationcontroller-and-your-own-views/</link>
		<comments>http://www.totodotnet.net/2009/06/13/how-to-enable-autorotation-when-combining-uitabbarcontroller-and-uinavigationcontroller-and-your-own-views/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 08:19:48 +0000</pubDate>
		<dc:creator>tonny.xu</dc:creator>
				<category><![CDATA[iPhone Dev]]></category>
		<category><![CDATA[AutoRotation]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[UITabBarController]]></category>

		<guid isPermaLink="false">http://www.totodotnet.net/2009/06/13/how-to-enable-autorotation-when-combining-uitabbarcontroller-and-uinavigationcontroller-and-your-own-views/</guid>
		<description><![CDATA[My app is still not online now, because I have to fix some autorotation problems. Before today, I really didn’t know how to enable autorotation when my app is combined with UITabBarController and UINavigationController and my own views. After doing a little search, The solution is I need to enable autorotation for every view controller [...]]]></description>
			<content:encoded><![CDATA[<p>My app is still not online now, because I have to fix some autorotation problems. Before today, I really didn’t know how to enable autorotation when my app is combined with UITabBarController and UINavigationController and my own views. After doing a little search, The solution is I need to enable autorotation for every view controller that will be presented in the UITabBarController.</p>
<p>Let’s assume we have a UITabBarController, theTabBarController and 3 UINavigationController named A, B, C. We need to set all the three controllers(A, B, C) to return YES in this method:</p>
<pre class="csharpcode">- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    <span class="rem">// Return YES for supported orientations</span>
    <span class="kwrd">return</span> YES;
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>OK, now your tab bar and navigation bar and your views will be automatically rotated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totodotnet.net/2009/06/13/how-to-enable-autorotation-when-combining-uitabbarcontroller-and-uinavigationcontroller-and-your-own-views/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>June 8th, is the iPhone Day!</title>
		<link>http://www.totodotnet.net/2009/06/09/june-8th-is-the-iphone-day/</link>
		<comments>http://www.totodotnet.net/2009/06/09/june-8th-is-the-iphone-day/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 07:44:15 +0000</pubDate>
		<dc:creator>tonny.xu</dc:creator>
				<category><![CDATA[iPhone Dev]]></category>
		<category><![CDATA[3rd Generation]]></category>
		<category><![CDATA[APNS]]></category>
		<category><![CDATA[In App Purchase]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.totodotnet.net/2009/06/09/june-8th-is-the-iphone-day/</guid>
		<description><![CDATA[Yesterday, technically, today, June 8th, is the iPhone Day! WWDC was opened about 14H ago, and almost all the main IT news channel are full of iPhone, We really need to celebrate it, 8th June, the iPhone Day.
OK, Let me tell you what’s my interest in iPhone Day.

The Rumor was real! 
The new iPhone release [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, technically, today, June 8th, is the iPhone Day! WWDC was opened about 14H ago, and almost all the main IT news channel are full of iPhone, We really need to celebrate it, 8th June, the iPhone Day.</p>
<p>OK, Let me tell you what’s my interest in iPhone Day.</p>
<ul>
<li><a href="http://www.totodotnet.net/2009/05/31/iphone-3rd-generation-new-features-exposed/" target="_blank"><strong>The Rumor</strong></a> was real! </li>
<li>The <strong>new iPhone release date, June 19</strong>, was a little bit earlier than I expected.<a href="http://www.totodotnet.net/wp-content/uploads/2009/06/iphone3gsreleasedate.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="iPhone3GS, Release Date" border="0" alt="iPhone3GS, Release Date" src="http://www.totodotnet.net/wp-content/uploads/2009/06/iphone3gsreleasedate-thumb.png" width="586" height="237" /></a> </li>
<li>Will Apple unlock the <a href="http://www.macrumors.com/2009/05/11/chinese-forum-poster-claims-next-generation-iphone-details/" target="_blank">CPU limitation</a> of current iPhone 3G? Still unknown.</li>
<li><strong>In App Purchase</strong> is really, really what I need. But I could not catch the iPhone 3GS release time.<a href="http://www.totodotnet.net/wp-content/uploads/2009/06/picture5.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Picture 5" border="0" alt="Picture 5" src="http://www.totodotnet.net/wp-content/uploads/2009/06/picture5-thumb.png" width="255" height="129" /></a> </li>
<li>I must work much more hard to get my app released.</li>
</ul>
<p>Damn it, I like iPhone!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totodotnet.net/2009/06/09/june-8th-is-the-iphone-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t use [AVAudioPlayer pause]</title>
		<link>http://www.totodotnet.net/2009/06/02/dont-use-avaudioplayer-pause/</link>
		<comments>http://www.totodotnet.net/2009/06/02/dont-use-avaudioplayer-pause/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 08:32:12 +0000</pubDate>
		<dc:creator>tonny.xu</dc:creator>
				<category><![CDATA[iPhone Dev]]></category>
		<category><![CDATA[AVAudioPlayer]]></category>
		<category><![CDATA[CoreAudio]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.totodotnet.net/2009/06/02/dont-use-avaudioplayer-pause/</guid>
		<description><![CDATA[AVAudioPlayer is providing a very convenient way to play iPhone supported audio file. Especially, if you want to implement fast forward and rewind, AVAudioPlayer is the best choice.
But I just found an odd problem. If I use [AVAudioPlayer pause] method, next time if I invoke [AVAudioPlayer play], it had no responde. But after I changed [...]]]></description>
			<content:encoded><![CDATA[<p>AVAudioPlayer is providing a very convenient way to play iPhone supported audio file. Especially, if you want to implement fast forward and rewind, AVAudioPlayer is the best choice.</p>
<p>But I just found an odd problem. If I use [AVAudioPlayer pause] method, next time if I invoke [AVAudioPlayer play], it had no responde. But after I changed pause to stop, it worked fine. The problem looks like it somewhere inside AVAudioPlayer to control the AudioQueue Object to resume playing. Whatever, by using [AVAudioPlayer stop], you can archive the same goal as [AVAudioPlayer pause] do, I mean FFW and RWD.</p>
<p>BTW, the document said, pause will return YES/NO, but clearly, it is a no return value instance method. The guy who is responsible for this method might copied the same comment from play!</p>
<p><a href="http://www.totodotnet.net/wp-content/uploads/2009/06/picture1.png"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="Picture 1" border="0" alt="Picture 1" src="http://www.totodotnet.net/wp-content/uploads/2009/06/picture1-thumb.png" width="642" height="282" /></a> </p>
<p>What a joke. This line was there since iPhone 2.2, and is still there in 3.0b5. Didn’t there anybody reported this problem? Should I fire a bug?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totodotnet.net/2009/06/02/dont-use-avaudioplayer-pause/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AVAudioPlayer could not play after recording via AudioQueue Object.</title>
		<link>http://www.totodotnet.net/2009/05/31/avaudioplayer-could-not-play-after-recording-via-audioqueue-object/</link>
		<comments>http://www.totodotnet.net/2009/05/31/avaudioplayer-could-not-play-after-recording-via-audioqueue-object/#comments</comments>
		<pubDate>Sun, 31 May 2009 02:44:09 +0000</pubDate>
		<dc:creator>tonny.xu</dc:creator>
				<category><![CDATA[iPhone Dev]]></category>
		<category><![CDATA[AVAudioPlayer]]></category>
		<category><![CDATA[CoreAudio]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.totodotnet.net/2009/05/31/avaudioplayer-could-not-play-after-recording-via-audioqueue-object/</guid>
		<description><![CDATA[Problem
I&#8217;ve been fighting for AVAudioPlayer and AudioQueue object for 2 days,    
Here is my Dev environment:    iPhone: 3.0Beta 5    OSX 10.5.7
Here is my scenario:   1. I need to use AVAudioPlayer to play a CAF with IMA4 data format. Including fast forward and rewind.  [...]]]></description>
			<content:encoded><![CDATA[<h2>Problem</h2>
<p>I&#8217;ve been fighting for <font face="Courier New">AVAudioPlayer</font> and <font face="Courier New">AudioQueue</font> object for 2 days,    </p>
<p>Here is my Dev environment:    <br />iPhone: 3.0Beta 5    <br />OSX 10.5.7</p>
<p>Here is my scenario:   <br />1. I need to use <font face="Courier New">AVAudioPlayer</font> to play a CAF with IMA4 data format. Including fast forward and rewind.    <br />2. I need to use <font face="Courier New">AudioQueue</font> Object to record audio, because 3.0 has not go public yet.    <br />3. A common scenario is record an audio A, then play the original audio A&#8217;(Not the one recorded) or vice versa.</p>
<p>The problem is I could <strong>NOT</strong> play the A&#8217; file&#160; after I record file A.    <br /><font face="Courier New">[theAVAudioPlayer play]</font> always return <strong>NO</strong>, but <font face="Courier New">[theAVAudioPlayer prepareToPlay]</font> return <strong>YES</strong>.    <br />This situation only happened after I used the <font face="Courier New">AudioQueue</font> Object for recording. If I did not record, it always worked fine.</p>
<p>About the clean up.   <br />1. I released the <font face="Courier New">theAVAudioPlayer</font> object and set to nil each time after I finished playing.    <br />2. I closed the audio file and deposed the <font face="Courier New">AudioQueue</font> Object each time after I finished recording.</p>
<h2>Solution</h2>
<p>Thanks to <a href="https://devforums.apple.com/people/vitaleye">Vitali Molodtsov</a>[<a href="https://devforums.apple.com/message/74707#74707" target="_blank">Open the original post</a> Needs login], the solution is reset the <font face="Courier New">AudioSessionCategory</font> to <font face="Courier New"><strong>kAudioSessionCategory_MediaPlayback</strong></font> just after finish recording. Then every thing goes fine.</p>
<h2>Conclusion</h2>
<p>I think this is a bug for <font face="Courier New">AVAudioPlayer</font>. Each time, when we initialize an <font face="Courier New">AVAudioPlayer</font> object, it should set the correct <font face="Courier New">AudioSessionCategory</font> for us silently, but it doesn’t. So I’ve fired a bug for Apple. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.totodotnet.net/2009/05/31/avaudioplayer-could-not-play-after-recording-via-audioqueue-object/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Best Way to Declare a Constant in Objective-C</title>
		<link>http://www.totodotnet.net/2009/05/29/the-best-way-to-declare-a-constant-in-objective-c/</link>
		<comments>http://www.totodotnet.net/2009/05/29/the-best-way-to-declare-a-constant-in-objective-c/#comments</comments>
		<pubDate>Fri, 29 May 2009 07:06:13 +0000</pubDate>
		<dc:creator>tonny.xu</dc:creator>
				<category><![CDATA[iPhone Dev]]></category>
		<category><![CDATA[Constants]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective-C 2.0]]></category>

		<guid isPermaLink="false">http://www.totodotnet.net/2009/05/29/the-best-way-to-declare-a-constant-in-objective-c/</guid>
		<description><![CDATA[Thanks to Barry Wark From [Here]
Create a header file like 
// Constants.h
extern NSString * const MyFirstConstant;
extern NSString * const MySecondConstant;
//etc. 

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to <a href="http://stackoverflow.com/users/2140/barry-wark" target="_blank">Barry Wark</a> From [<a href="http://stackoverflow.com/questions/538996/constants-in-objective-c" target="_blank">Here</a>]</p>
<p>Create a header file like </p>
<pre class="csharpcode"><span class="rem">// Constants.h</span>
<span class="kwrd">extern</span> NSString * <span class="kwrd">const</span> MyFirstConstant;
<span class="kwrd">extern</span> NSString * <span class="kwrd">const</span> MySecondConstant;
//etc. </pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>You can include this file in each file that uses the constants or in the pre-compiled header for the project. </p>
<p>You define these constants in a .m file like </p>
<pre class="csharpcode"><span class="rem">// Constants.m</span>
NSString * <span class="kwrd">const</span> MyFirstConstant = <span class="str">@&quot;FirstConstant&quot;</span>;
NSString * <span class="kwrd">const</span> MySecondConstant = <span class="str">@&quot;SecondConstant&quot;</span>; </pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Constants.m should be added to your application/framework&#8217;s target so that it is linked in to the final product. </p>
<p>The advantage of using string constants instead of <font face="Courier New">#define </font>constants is that you can test for equality using pointer comparison<font face="Courier New"> (stringInstance == MyFirstConstant)</font> which is much faster than string comparison <font face="Courier New">([stringInstance isEqualToString:MyFirstConstant])</font> (and easier to read, IMO).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totodotnet.net/2009/05/29/the-best-way-to-declare-a-constant-in-objective-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A Weird Exception from iPhone Simulator</title>
		<link>http://www.totodotnet.net/2009/05/25/a-weird-exception-from-iphone-simulator/</link>
		<comments>http://www.totodotnet.net/2009/05/25/a-weird-exception-from-iphone-simulator/#comments</comments>
		<pubDate>Mon, 25 May 2009 02:56:56 +0000</pubDate>
		<dc:creator>tonny.xu</dc:creator>
				<category><![CDATA[iPhone Dev]]></category>
		<category><![CDATA[AudioUnit]]></category>
		<category><![CDATA[CoreAudio]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.totodotnet.net/2009/05/25/a-weird-exception-from-iphone-simulator/</guid>
		<description><![CDATA[Today I met a weird exception from AUGraphStart(). 
Basically, I was running an old sample code written by myself. The main function is mix 2 audio files a playback them simultaneously. I worked fine before, but when I run it, I got this exception: 
[00:23:58.425 &#60;AURemoteIOServer&#62;] AQMEIOBase::DoStartIO: timeout
[00:23:58.701 &#60;AURemoteIOServer&#62;] AQMEDevice::StartIO: AudioOutputUnitStart returned -66681
[00:23:58.701 &#60;0xa084a720&#62;] AUIOClient_StartIO [...]]]></description>
			<content:encoded><![CDATA[<p>Today I met a weird exception from <font face="Courier New">AUGraphStart()</font>. </p>
<p>Basically, I was running an old sample code written by myself. The main function is mix 2 audio files a playback them simultaneously. I worked fine before, but when I run it, I got this exception: </p>
<pre class="csharpcode">[00:23:58.425 &lt;AURemoteIOServer&gt;] AQMEIOBase::DoStartIO: timeout
[00:23:58.701 &lt;AURemoteIOServer&gt;] AQMEDevice::StartIO: AudioOutputUnitStart returned -66681
[00:23:58.701 &lt;0xa084a720&gt;] AUIOClient_StartIO failed (-66681)
AUGraphStart FFFEFB87 </pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Obviously, it wasn&#8217;t came from my code, and I have no idea on this exception now. Did anybody get a same exception recently? </p>
<p>I had tried these: </p>
<p>&#160;&#160; 1. Restart the XCode. &#8212; No effects.<br />
  <br />&#160;&#160; 2. Restart the machine(Mac Pro, 10.5.7), and restart the XCode. &#8212; No effects. </p>
<p>&#160;&#160; 3. Reinstall the most recent SDK(Build 9M2735), restart the XCode. &#8212; No effects. </p>
<p>&#160;&#160; 4. Set the base SDK to 2.2.1 and target to Simulator 2.2.1 Debug. &#8212; No effects. </p>
<p>It&#8217;s really odd! </p>
<p>Please, if anybody had met similar exception and got a solution, help me out!</p>
<p>Still don’t know how to resolve it now. I need&#160; help!</p>
<p><strong><font color="#ff0000">[Update 2009-06-11]</font></strong></p>
<p>A week ago, Apple’s engineer had confirmed that they had a bug in UIKit framework. </p>
<blockquote>
<p>We do have a simple workaround for this UIKit bug. In UILocalizedIndexedCollation.hm change this:<br />
    <br />&#160; <strong><font color="#ff0000">UIKIT_EXTERN</font></strong> @interface UILocalizedIndexedCollation : NSObject</p>
<p>to</p>
<p>&#160; <strong><font color="#ff0000">UIKIT_EXTERN_CLASS</font></strong> @interface UILocalizedIndexedCollation : NSObject </p>
<p>Having done that, we can build your project and confirm that AUGraphStart returns 0 in the 3.0 simulator.</p>
<p>&#160;</p>
</blockquote>
<p>But, after I installed the <font color="#ff0000">3.0 GM Version</font> today, it’s still not included in the GM Version. So that means I still can not play audio in the simulator. I can ONLY do it on the device!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totodotnet.net/2009/05/25/a-weird-exception-from-iphone-simulator/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>
