<?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> &#187; iPhone</title>
	<atom:link href="http://blog.blazingcloud.net/tag/iphone/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.blazingcloud.net</link>
	<description></description>
	<lastBuildDate>Tue, 04 Jun 2013 18:20:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>KIFTests talk</title>
		<link>http://blog.blazingcloud.net/2012/09/17/kiftests-talk/</link>
		<comments>http://blog.blazingcloud.net/2012/09/17/kiftests-talk/#comments</comments>
		<pubDate>Mon, 17 Sep 2012 17:00:21 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[iPod]]></category>
		<category><![CDATA[Objective-c]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://blog.blazingcloud.net/?p=3486</guid>
		<description><![CDATA[You can use iPhone speech synthesizer to announce runs of integration tests. Hear the sounds what will warm your heart every time. It shows that tests are working. Starting 13 test scenarios If you have Siri on your phone Siri&#8217;s voice will pronounce the phrases. VSSpeechSynthesizer could be found in XCode 4.4 in iOS PrivateFrameworks [...]]]></description>
			<content:encoded><![CDATA[<p>You can use iPhone speech synthesizer to announce runs of integration tests.<br />
Hear the sounds what will warm your heart every time. It shows that tests are working.</p>
<p><a href='http://blog.blazingcloud.net/wp-content/start.m4a' rel='attachment wp-att-3499'>Starting 13 test scenarios</a></p>
<p><object><param name="autostart" value="false"><param name="src" value="http://blog.blazingcloud.net/wp-content/start.m4a"><param name="autoplay" value="false"><param name="controller" value="true"><embed src="http://blog.blazingcloud.net/wp-content/start.m4a" controller="true" autoplay="false" autostart="false" type="audio/m4a" /><br />
</object></p>
<p>If you have Siri on your phone Siri&#8217;s voice will pronounce the phrases.</p>
<p>VSSpeechSynthesizer could be found in XCode 4.4 in iOS PrivateFrameworks<br />
<code><br />
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/PrivateFrameworks/VoiceServices.framework</code><br />
&nbsp;<br />
Add new <code>VSSpeechSynthesizer.h:</code></p><pre class="crayon-plain-tag">
// VSSpeechSynthesizer.h
@interface VSSpeechSynthesizer : NSObject {}
+ (id)availableLanguageCodes;
+ (BOOL)isSystemSpeaking;
- (id)startSpeakingString:(id)string;
- (id)startSpeakingString:(id)string toURL:(id)url;
- (id)startSpeakingString:(id)string toURL:(id)url withLanguageCode:(id)code;
- (float)rate;              // default rate: 1
- (id)setRate:(float)rate;
- (float)pitch;             // default pitch: 0.5
- (id)setPitch:(float)pitch;
- (float)volume;            // default volume: 0.8
- (id)setVolume:(float)volume;
@end</pre><p></p>
<p>Add to your <code>EXTestController.m</code></p><pre class="crayon-plain-tag">
VSSpeechSynthesizer *synthesizer;

- (void)initializeScenarios {
    ...
    synthesizer = [VSSpeechSynthesizer new];
}

- (void)startTestingWithCompletionBlock:(KIFTestControllerCompletionBlock)inCompletionBlock {
    [synthesizer startSpeakingString:@&quot;starting testing&quot;];
    ...
}</pre><p></p>
<p>Next if you like your test to speak on iOS Simulator too you can add this implementation of<br />
VSSpeechSynthesizer</p>
<p></p><pre class="crayon-plain-tag">
#import &quot;VSSpeechSynthesizer.h&quot;

#if TARGET_IPHONE_SIMULATOR

@implementation VSSpeechSynthesizer
+ (id)availableLanguageCodes {
    return nil;
}
+ (BOOL)isSystemSpeaking {
    return NO;
}

-(NSString *)selectVoiceForPhrase:(NSString *)phrase {
    NSDictionary *keywordToVoice = @{
    @&quot;failures!&quot; : @&quot;Bad&quot;,
    @&quot;failure!&quot; : @&quot;Bruce&quot;,
    @&quot;FAIL&quot; : @&quot;Agnes&quot;
    };
    NSString *keyword = nil;
    for (keyword in [keywordToVoice allKeys]) {
        BOOL found = NSNotFound != [phrase rangeOfString:keyword].location;
        if (found) {
            break;
        }
    }
    return keyword ? [keywordToVoice objectForKey:keyword] : @&quot;Vicki -r 150&quot;;
}

- (id)startSpeakingString:(id)what {
    NSString *voice = [self selectVoiceForPhrase:what];
    NSString *command = [NSString stringWithFormat:@&quot;say -v %@ %@&quot;, voice, what];
    system([command cStringUsingEncoding:NSASCIIStringEncoding]);
    DLogObject(what);
    return nil;
}
- (id)startSpeakingString:(id)string toURL:(id)url {
    return nil;
}
- (id)startSpeakingString:(id)string toURL:(id)url withLanguageCode:(id)code {
    return nil;
}
- (float)rate {
    return 1;
}
- (id)setRate:(float)rate {
    return nil;
}
- (float)pitch {
    return 0.5;
}
- (id)setPitch:(float)pitch {
    return nil;
}
- (float)volume {
    return 0.8;
}
- (id)setVolume:(float)volume {
    return nil;
}
@end
#endif</pre><p></p>
<p>Hear the sound of all tests passed.</p>
<p><a href='http://blog.blazingcloud.net/wp-content/end.m4a' rel='attachment wp-att-3499'>All 13 Tests Passed</a></p>
<p><object><param name="autostart" value="false"><param name="src" value="http://blog.blazingcloud.net/wp-content/end.m4a"><param name="autoplay" value="false"><param name="controller" value="true"><embed src="http://blog.blazingcloud.net/wp-content/end.m4a" controller="true" autoplay="false" autostart="false" type="audio/m4a" /><br />
</object></p>
<p>Next we added an announcement of the first failure in the test suite to help us debug the issue. That announcement comes from a voice called &#8220;bad news&#8221; logically. See more voices available on Mac OS X System Preferences Speech panel:<br />
<a href="http://blog.blazingcloud.net/?attachment_id=3563"><img src="http://blog.blazingcloud.net/wp-content//mac_os_x_speech_voices.png" alt="" title="mac_os_x_speech_voices" class="alignnone size-full wp-image-3563" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.blazingcloud.net/2012/09/17/kiftests-talk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://blog.blazingcloud.net/wp-content/start.m4a" length="43193" type="audio/mpeg" />
<enclosure url="http://blog.blazingcloud.net/wp-content/end.m4a" length="51734" type="audio/mpeg" />
		</item>
		<item>
		<title>iPad custom fonts</title>
		<link>http://blog.blazingcloud.net/2010/09/28/ipad-custom-fonts/</link>
		<comments>http://blog.blazingcloud.net/2010/09/28/ipad-custom-fonts/#comments</comments>
		<pubDate>Wed, 29 Sep 2010 04:17:36 +0000</pubDate>
		<dc:creator>pablokang</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://blazingcloud.net/?p=1445</guid>
		<description><![CDATA[Wish I had found this doc earlier for a project I just completed. So custom fonts can be embedded in iOS 3.2 as described in What&#8217;s New in iOS: iOS 3.2: Custom Font Support Applications that want to use custom fonts can now include those fonts in their application bundle and register those fonts with [...]]]></description>
			<content:encoded><![CDATA[<p>Wish I had found this doc earlier for a project I just completed. So custom fonts can be embedded in iOS 3.2 as described in <a href="http://developer.apple.com/library/ios/prerelease/#releasenotes/General/WhatsNewIniPhoneOS/Articles/iPhoneOS3_2.html">What&#8217;s New in iOS: iOS 3.2</a>:</p>
<blockquote><p><strong>Custom Font Support</strong><br />
Applications that want to use custom fonts can now include those fonts in their application bundle and register those fonts with the system by including the UIAppFonts key in their Info.plist file. The value of this key is an array of strings identifying the font files in the application’s bundle. When the system sees the key, it loads the specified fonts and makes them available to the application.</p>
<p>For more information about the keys you can include in your application’s Info.plist file, see Information Property List Key Reference.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.blazingcloud.net/2010/09/28/ipad-custom-fonts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BieberFy</title>
		<link>http://blog.blazingcloud.net/2010/09/23/bieberfy/</link>
		<comments>http://blog.blazingcloud.net/2010/09/23/bieberfy/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 22:12:10 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Products]]></category>
		<category><![CDATA[BieberFy]]></category>
		<category><![CDATA[iPod]]></category>

		<guid isPermaLink="false">http://blazingcloud.net/?p=1291</guid>
		<description><![CDATA[Here at Blazing Cloud we are happy to announce the launch of our first official product, BieberFy! BieberFy was inspired by Justin Bieber and the overwhelming response to his floppy teenage hair cut. So we thought, what would be better then to make an app that could give anyone Justin Bieber&#8217;s hair du? I mean, [...]]]></description>
			<content:encoded><![CDATA[<p><a style="display:block;" href="http://itunes.apple.com/us/app/bieberfy/id388475374?mt=8"><br />
<img style="display:block;margin:auto;margin-left:auto;margin-right:auto;" src="http://img.skitch.com/20100923-m4d99j6ukq6iexc9xe7cxen9y4.png" alt="BieberFy Icon" /><br />
<img style="display:block;margin:auto;margin-left:auto;margin-right:auto;" src="http://img.skitch.com/20100923-tfys8j49dm3rpckhpqhp2mf5t3.png" alt="BieberFy Logo" width="200" height="50" /><br />
</a></p>
<p>Here at Blazing Cloud we are happy to announce the launch of our first official product, <a href="http://itunes.apple.com/us/app/bieberfy/id388475374?mt=8">BieberFy</a>! BieberFy was inspired by Justin Bieber and the overwhelming response to his floppy teenage hair cut. So we thought, what would be better then to make an app that could give anyone Justin Bieber&#8217;s hair du? I mean, haven&#8217;t you always wondered what you would look like with Justin Bieber&#8217;s hair? Okay, maybe thats a stretch, wondering what you would look like with Justin Biebers likeness and all, but if  your curiosity gets the better of you there IS an app for that now.</p>
<p>BieberFy is an application that runs on iOS 4 for the iPhone and iPod touch. BieberFy takes advantage of the devices built in camera by displaying an overlay that gives you three Justin Bieber hair styles to choose from.  The initial version of the app allows you to take a photo with one of the hair styles, preview it and if you choose to accept, it will save it to the device&#8217;s built in photo album.</p>
<p>BieberFy is available for sale world wide via the iTunes app store for $0.99.</p>
<p>We hope you have just as much fun with this app as we do!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.blazingcloud.net/2010/09/23/bieberfy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQTouch slide transition fix for Android 2.0</title>
		<link>http://blog.blazingcloud.net/2010/08/11/jqtouch-slide-transition-fix-for-android-2-0/</link>
		<comments>http://blog.blazingcloud.net/2010/08/11/jqtouch-slide-transition-fix-for-android-2-0/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 19:29:25 +0000</pubDate>
		<dc:creator>pablokang</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[jqtouch]]></category>

		<guid isPermaLink="false">http://blazingcloud.net/?p=1074</guid>
		<description><![CDATA[A client of Blazing Cloud recently wanted to support animated screen transitions in their mobile platform and came to us for help. We decided to integrate the latest jQTouch (version 1, beta 2) into their framework since we had heard good things about it. Unfortunately, many animated transitions in Android don&#8217;t work very well. Worst [...]]]></description>
			<content:encoded><![CDATA[<p>A client of Blazing Cloud recently wanted to support animated screen transitions in their mobile platform and came to us for help. We decided to integrate the latest <a href="http://www.jqtouch.com/">jQTouch</a> (version 1, beta 2) into their framework since we had heard good things about it. Unfortunately, many animated transitions in Android don&#8217;t work very well. Worst is that slide transitions don&#8217;t work at all on Android 2.0 devices.</p>
<p>After poking around a bit, it seemed that the @-webkit-keyframes styles in jqtouch.css defined for the sliding transitions were being applied in parallel when running in Android 2.0. For example, a slide-in-from-right link  has these webkit animated styles applied to it:</p><pre class="crayon-plain-tag">.in, .out {
    -webkit-animation-timing-function: ease-in-out;
    -webkit-animation-duration: 350ms;
}

.slide.in {
    -webkit-animation-name: slideinfromright;
}

@-webkit-keyframes slideinfromright {
    from { -webkit-transform: translateX(100%); }
    to { -webkit-transform: translateX(0); }
}</pre><p>On  iPhone and Android 1.0 devices,  a slide-in-from-right screen slides in correctly from 100% to 0 in about 350ms. But on Android 2.0 devices,  the screen appears immediately as if no animation occurred.</p>
<p>To work around this problem,  you have to manually set the start position first, then the end position and animation style. That is, instead of letting the @-webkit-keyframes do the work, you have to manually position the screen at 100%, then set the animation  and final position style after a small time interval. For example, the key portion of the code to consider  is:</p><pre class="crayon-plain-tag">toPage.css(&amp;quot;webkitTransform&amp;quot;, &amp;quot;translate3d(100%,0px,0px)&amp;quot;);
setTimeout(function() {
    toPage.css({webkitTransitionDuration: &amp;quot;350ms&amp;quot;,
    webkitTransitionTimingFunction: &amp;quot;ease-in-out&amp;quot;});
    toPage.css(&amp;quot;webkitTransform&amp;quot;, &amp;quot;translate3d(0px,0px,0px)&amp;quot;);
}, 5);</pre><p>Note that we first set the starting position then wait about 5 milliseconds before applying the animated style (webkitTransitionDuration and webkitTransitionTimingFunction). After the transition completes, I clear the style from the page:</p><pre class="crayon-plain-tag">toPage.css({webkitTransitionDuration: null,
            webkitTransitionTimingFunction: null})</pre><p>The sliding animation is handled in the animatePages function. Here&#8217;s the code with workaround (my changes in bold):</p><pre class="crayon-plain-tag">function animatePages(fromPage, toPage, animation, backwards) {
    // Error check for target page
    if(toPage.length === 0){
        $.fn.unselect();
        console.error('Target element is missing.');
        return false;
    }

    // Collapse the keyboard
    $(':focus').blur();

    // Make sure we are scrolled up to hide location bar
    scrollTo(0, 0);

    // Define callback to run after animation completes
    var callback = function(event){

        if (animation)
        {
            if (animation.name == &amp;quot;slide&amp;quot;) {
                var css = {webkitTransitionDuration: null,
                    webkitTransitionTimingFunction: null};
                toPage.css(css);
                fromPage.css(css);
            }
            toPage.removeClass('in reverse ' + animation.name);
            fromPage.removeClass('current out reverse ' + animation.name);
        }
        else
        {
            fromPage.removeClass('current');
        }

        toPage.trigger('pageAnimationEnd', { direction: 'in' });
        fromPage.trigger('pageAnimationEnd', { direction: 'out' });

        clearInterval(dumbLoop);
        currentPage = toPage;
        location.hash = currentPage.attr('id');
        dumbLoopStart();

        var $originallink = toPage.data('referrer');
        if ($originallink) {
            $originallink.unselect();
        }
        lastAnimationTime = (new Date()).getTime();
        tapReady = true;
    }

    fromPage.trigger('pageAnimationStart', { direction: 'out' });
    toPage.trigger('pageAnimationStart', { direction: 'in' });

    if ($.support.WebKitAnimationEvent &amp;amp;&amp;amp;
        animation &amp;amp;&amp;amp;
        jQTSettings.useAnimations) {
        tapReady = false;
        if (animation.name == &amp;quot;slide&amp;quot;) {
            toPage.one('webkitTransitionEnd', callback);
            toPage.addClass('in current');
            fromPage.addClass('out');
            toPage.css(&amp;quot;webkitTransform&amp;quot;, 
                       &amp;quot;translate3d(&amp;quot; + (backwards ? &amp;quot;-100%&amp;quot; : &amp;quot;100%&amp;quot;) + &amp;quot;,0px,0px)&amp;quot;);
            fromPage.css(&amp;quot;webkitTransform&amp;quot;, 
                         &amp;quot;translate3d(0px,0px,0px)&amp;quot;);
            setTimeout(function() {
                var css = {webkitTransitionDuration: &amp;quot;350ms&amp;quot;,
                    webkitTransitionTimingFunction: &amp;quot;ease-in-out&amp;quot;};
                toPage.css(css);
                fromPage.css(css);
                toPage.css(&amp;quot;webkitTransform&amp;quot;,
                           &amp;quot;translate3d(0px,0px,0px)&amp;quot;);
                fromPage.css(&amp;quot;webkitTransform&amp;quot;,
                             &amp;quot;translate3d(&amp;quot; + (backwards ? &amp;quot;100%&amp;quot; : &amp;quot;-100%&amp;quot;) + &amp;quot;,0px,0px)&amp;quot;);
            }, 5);
        } else {
            toPage.one('webkitAnimationEnd', callback);
            toPage.addClass(animation.name + ' in current ' + (backwards ? ' reverse' : ''));
            fromPage.addClass(animation.name + ' out' + (backwards ? ' reverse' : ''));
        }
    } else {
        toPage.addClass('current');
        callback();
    }

    return true;
}</pre><p>Note that jQTouch sets <em>$.support.WebKitAnimationEvent</em> to false for Android 2.0 devices even though it does support WebKit animation. Make sure you set that to true. Replace the animatePage function in your jQtouch with the function in this post and now  you should be golden with iPhone and Android!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.blazingcloud.net/2010/08/11/jqtouch-slide-transition-fix-for-android-2-0/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>What&#039;s weird about floats in objective-c?</title>
		<link>http://blog.blazingcloud.net/2010/08/09/whats-weird-about-floats-in-objective-c-2/</link>
		<comments>http://blog.blazingcloud.net/2010/08/09/whats-weird-about-floats-in-objective-c-2/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 18:56:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective-c]]></category>

		<guid isPermaLink="false">http://blazingcloud.net/?p=1014</guid>
		<description><![CDATA[Aright, what&#8217;s up with this? This code using a double works just fine: [crayon-51c21c517ad19/] This code prints: myDouble 2.200000 testDouble 2.200000 No surprises there. But the same code using a float behaves very strangely: [crayon-51c21c517b4e5/] This code prints myFloat 3.300000 testFloat 36893488147419103232.000000 So what happens to the float that is passed to the testFloat method? [...]]]></description>
			<content:encoded><![CDATA[<p>Aright, what&#8217;s up with this? This code using a double works just fine:</p><pre class="crayon-plain-tag">
double myDouble = 2.2;
NSLog(@&amp;quot;myDouble %f&amp;quot;, myDouble);

[self testDouble:myDouble];

- (void) testDouble:(double)myDouble {
    NSLog(@&amp;quot;testDouble %f&amp;quot;, myDouble);
}</pre><p></p>
<p>This code prints:<br />
<strong><em>myDouble 2.200000<br />
testDouble 2.200000</em></strong></p>
<p>No surprises there. But the <em>same</em> code using a float behaves very strangely:</p><pre class="crayon-plain-tag">
float myFloat = 3.3;
NSLog(@&amp;quot;myFloat %f&amp;quot;, myFloat);

[self testFloat:myFloat];

- (void) testFloat:(float)myFloat {
    NSLog(@&amp;quot;testFloat %f&amp;quot;, myFloat);
}</pre><p></p>
<p><em>This</em> code prints<br />
<strong><em>myFloat 3.300000<br />
testFloat 36893488147419103232.000000</em></strong></p>
<p>So what happens to the float that is passed to the testFloat method? According to this Techtopia article about <a href="http://www.techotopia.com/index.php/Objective-C_2.0_Data_Types#float_Data_Type">Objective-C 2.0 Data Types</a> when you create a float like this:</p>
<p></p><pre class="crayon-plain-tag">
float myFloat = 3.3;</pre><p></p>
<p>It is internally stored as a double, which has greater precision. If you actually want to store something as a float you need to append an &#8220;f&#8221; to the number like this:</p><pre class="crayon-plain-tag">
float myFloat = 3.3f;</pre><p></p>
<p>So I thought perhaps that was the problem &#8211; that internally it was represented as a double, so when passed in to a method expecting a float there was a conversion error. But when I modified the code above to include the &#8220;f&#8221; I get the same result.</p>
<p>I also get the same result when I pass the float in directly to the method like this:</p><pre class="crayon-plain-tag">
[self testFloat:3.3f];</pre><p></p>
<p>So what the heck is going on here? Why can&#8217;t I pass a float to a method? What am I missing? I&#8217;ll follow up with a comment when I figure it out, but does anybody know why this is happening?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.blazingcloud.net/2010/08/09/whats-weird-about-floats-in-objective-c-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What&#8217;s weird about floats in objective-c?</title>
		<link>http://blog.blazingcloud.net/2010/08/09/whats-weird-about-floats-in-objective-c/</link>
		<comments>http://blog.blazingcloud.net/2010/08/09/whats-weird-about-floats-in-objective-c/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 18:56:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective-c]]></category>

		<guid isPermaLink="false">http://blazingcloud.net/?p=1014</guid>
		<description><![CDATA[Aright, what&#8217;s up with this? This code using a double works just fine: [crayon-51c21c517dfdf/] This code prints: myDouble 2.200000 testDouble 2.200000 No surprises there. But the same code using a float behaves very strangely: [crayon-51c21c517e7ad/] This code prints myFloat 3.300000 testFloat 36893488147419103232.000000 So what happens to the float that is passed to the testFloat method? [...]]]></description>
			<content:encoded><![CDATA[<p>Aright, what&#8217;s up with this? This code using a double works just fine:</p><pre class="crayon-plain-tag">
double myDouble = 2.2;
NSLog(@&amp;quot;myDouble %f&amp;quot;, myDouble);

[self testDouble:myDouble];

- (void) testDouble:(double)myDouble {
    NSLog(@&amp;quot;testDouble %f&amp;quot;, myDouble);
}</pre><p></p>
<p>This code prints:<br />
<strong><em>myDouble 2.200000<br />
testDouble 2.200000</em></strong></p>
<p>No surprises there. But the <em>same</em> code using a float behaves very strangely:</p><pre class="crayon-plain-tag">
float myFloat = 3.3;
NSLog(@&amp;quot;myFloat %f&amp;quot;, myFloat);

[self testFloat:myFloat];

- (void) testFloat:(float)myFloat {
    NSLog(@&amp;quot;testFloat %f&amp;quot;, myFloat);
}</pre><p></p>
<p><em>This</em> code prints<br />
<strong><em>myFloat 3.300000<br />
testFloat 36893488147419103232.000000</em></strong></p>
<p>So what happens to the float that is passed to the testFloat method? According to this Techtopia article about <a href="http://www.techotopia.com/index.php/Objective-C_2.0_Data_Types#float_Data_Type">Objective-C 2.0 Data Types</a> when you create a float like this:</p>
<p></p><pre class="crayon-plain-tag">
float myFloat = 3.3;</pre><p></p>
<p>It is internally stored as a double, which has greater precision. If you actually want to store something as a float you need to append an &#8220;f&#8221; to the number like this:</p><pre class="crayon-plain-tag">
float myFloat = 3.3f;</pre><p></p>
<p>So I thought perhaps that was the problem &#8211; that internally it was represented as a double, so when passed in to a method expecting a float there was a conversion error. But when I modified the code above to include the &#8220;f&#8221; I get the same result.</p>
<p>I also get the same result when I pass the float in directly to the method like this:</p><pre class="crayon-plain-tag">
[self testFloat:3.3f];</pre><p></p>
<p>So what the heck is going on here? Why can&#8217;t I pass a float to a method? What am I missing? I&#8217;ll follow up with a comment when I figure it out, but does anybody know why this is happening?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.blazingcloud.net/2010/08/09/whats-weird-about-floats-in-objective-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WWDC Day One</title>
		<link>http://blog.blazingcloud.net/2010/06/14/wwdc-day-one/</link>
		<comments>http://blog.blazingcloud.net/2010/06/14/wwdc-day-one/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 00:31:41 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[iPod]]></category>
		<category><![CDATA[Objective-c]]></category>
		<category><![CDATA[WWDC]]></category>

		<guid isPermaLink="false">http://blazingcloud.net/?p=849</guid>
		<description><![CDATA[Apples annual conference kicked off last week and Blazing Cloud wasn&#8217;t about to miss it&#8217;s chance to attend. Many exciting things happened like a preview of the 4th generation iPhone, a preview of developer tools and a look into safari improvements. The keynote also offered up some interesting statistics and new device capabilities of iPhone [...]]]></description>
			<content:encoded><![CDATA[<p>Apples annual conference kicked off last week and Blazing Cloud wasn&#8217;t about to miss it&#8217;s chance to attend. Many exciting things happened like a preview of the 4th generation iPhone, a preview of developer tools and a look into safari improvements. The keynote also offered up some interesting statistics and new device capabilities of iPhone 4 that we wanted to share with you.</p>
<h2>iBooks</h2>
<p>In the first 65 days users have download over 5 million books</p>
<h3>Enhancement to iBooks</h3>
<p>Highlight sections<br />
Make notes<br />
Bookmark the page in the corner<br />
View and read PDFs</p>
<h2>AppStore</h2>
<p>Apple supports two platforms, HTML5 and AppStore (225,000 apps)<br />
15,000 apps submitted every week supporting up to 30 languages<br />
95% of apps are approved in 7 days<br />
5% of apps get rejected</p>
<h3>Reason why apps are rejected from the AppStore</h3>
<p>Use of private Apple APIs<br />
App doesn&#8217;t work like developer says it works<br />
The app crashes</p>
<p>Downloads from the AppStore total 5 billion<br />
$1 billion dollars have been paid out to developers thus far</p>
<h2>iPhone stats</h2>
<h3>Us smartphone market share Q1 of 2010</h3>
<p>RIM 35%<br />
iPhone 28%<br />
Winmo 19%<br />
Android 9%<br />
Other 9%</p>
<h3>US mobile browsers share Q1 of 2010</h3>
<p>iPhone 58.2%<br />
Android 22.7%<br />
Rim 12.7%<br />
Other 6.4%</p>
<h2>iPhone 4</h2>
<h3>1st new feature</h3>
<p>All new design<br />
9.3 mm thick<br />
&#8220;Thinnest smartphone on the planet&#8221;<br />
Camera and LED flash<br />
2nd mic for noise cancellation<br />
Integrated Antennas in the structure of the phone<br />
Stainless steel body<br />
Glass on front and back</p>
<h3>2nd new feature</h3>
<p>Retina display<br />
4 times as many pixels in the same area<br />
326 pixels per inch<br />
300 pixels per inch is the limit of the human retina to differentiate pixels<br />
3.5 inches 960&#215;640<br />
800:1 contrast ratio<br />
IPS technology<br />
78% of the pixels on the iPad on the iPhone</p>
<h3>3rd new featured</h3>
<p>Powered by the A4 processor<br />
3G talk time equals 7 hours<br />
3G browsing time equals 6 hours<br />
WIFI browsing time equals 10hours<br />
32G and 16G storage options</p>
<h3>4th new feature</h3>
<p>3 Axis Gyroscope<br />
Pitch, roll and yaw<br />
Rotation about gravity<br />
Gyro plus accelerometer provides 6 axis</p>
<h3>5th new feature</h3>
<p>New camera system<br />
5megapixel sensor<br />
Backside illuminated sensor<br />
5x digital zoom<br />
LED flash built in<br />
HD video recording 720p at 30 frames per sec<br />
Built in video editing (iMovie application)<br />
LED flash will stay on for video</p>
<h3>6th new feature</h3>
<p>Renaming iPhone OS to iOS 4<br />
1500 new developer APIs<br />
100 new user features<br />
Multitasking<br />
Folders<br />
Added bing as a search option (with google and yahoo)</p>
<p>Golden master candidate released June 7th</p>
<p>100th million iOS device (iPhone + ipads + iPods) sold</p>
<h3>7th new feature</h3>
<p>iBooks coming to iPhone<br />
Same features as the iPad<br />
Wireless sync between iPhone, iPad and iPod touch<br />
Same books for all devices at no extra charge</p>
<p>150 million accounts with credit cards (iBook store, AppStore and iTunes Store)<br />
Over 16 billion downloads from all three stores</p>
<h3>8th new feature</h3>
<p>iADs<br />
Ads keep you in your app which gives a better user experience<br />
Built right into iOS4<br />
Brands so far to sign up (within the last 8 weeks): Nissan, Citi, unilever, AT&amp;T, Chenel, GE, liberty mutual, State Farm, Gieco, Cambell, Sears, JCPennys, Target, Best Buy, DirecTV, tbs, and Disney</p>
<p>These companies committed 60 million dollars towards iAds</p>
<h3>9th new feature</h3>
<p>FaceTime video calling<br />
Uses wifi, no setup required<br />
Use front or rear camera<br />
Wifi only in 2010 have to work with the cellular companies to get their networks ready for video calling</p>
<h2>Price and availability</h2>
<p>2 colors white or black<br />
$299 for 32 gig $199 for 16 gig<br />
On sale June 24th<br />
Pre-sale June 15th</p>
<p>iOS 4 upgrades are free for everyone (iPhone + iPod Touch)!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.blazingcloud.net/2010/06/14/wwdc-day-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test Driven Development for iPhone</title>
		<link>http://blog.blazingcloud.net/2010/02/20/test-driven-development-for-iphone/</link>
		<comments>http://blog.blazingcloud.net/2010/02/20/test-driven-development-for-iphone/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 02:07:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective-c]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://blazingcloud.net/?p=422</guid>
		<description><![CDATA[UPDATE: Check out the project source code at: http://github.com/blazingcloud/iphone_logic_testing Here at Blazing Cloud we really like Test-Driven Development (TDD). We try to use it for all of our development projects, and we recently learned how to do it for IPhone development. The unit test tool available for Cocoa development is more like JUnit for Java [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE:<br />
Check out the project source code at: http://github.com/blazingcloud/iphone_logic_testing</strong></p>
<p>Here at Blazing Cloud we really like Test-Driven Development (TDD). We try to use it for all of our development projects, and we recently learned how to do it for IPhone development. </p>
<p>The unit test tool available for Cocoa development is more like JUnit for Java than RSpec for Ruby. Each test is implemented as a method, and it is described by its method name, so you need to get creative with camel case. In addition, the error messages that you get out of the c compiler are difficult to parse (at least to those of us with limited c experience), which makes the <em>watch it fail first and then fix it</em> methodology difficult. However, it is still worth suffering in the unfriendly environment to get the benefits of a full test suite. Hopefully the knowledge that we gained in muddling through this will help you get started in your own project.</p>
<p><strong>There are two types of tests suites for IPhone development: Logic Tests and Application Tests. </strong></p>
<ul>
<li><strong>Logic Tests</strong> test business logic and are run independently of any device (including the emulator). </li>
<li><strong>Application Tests</strong> test the UI and everything that can only be tested on the device.</li>
</ul>
<p>This article will detail how to develop business logic code using Logic Tests. We will follow up with Application Testing in a subsequent article.  The Apple developer site has documentation for <a href="http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/135-Unit_Testing_Applications/unit_testing_applications.html">Unit Testing Applications</a>, and you may want to read this document first. We will walk through the set-up in this article but if you need more detail you may find it in the Apple site. </p>
<h2>Logic Testing</h2>
<p>We will now demonstrate Logic Testing using a simple tip calculator as an example. To begin (with iPhone SDK and Xcode installed) launch XCode and create a new View Based IPhone Application called TipCalc. As a sanity check you can try to run this empty app in the simulator and you will see an empty view screen.</p>
<p>Make a new target for your logic tests. Right click <strong>Targets</strong> and select <strong>Add</strong> -> <strong>New Target</strong>. Select <strong>Unit Test Bundle</strong> and name the bundle &#8220;Logic Tests&#8221;. You can close the little info window that comes up, and you will see your new target in the <strong>Targets</strong> group.</p>
<p>Create a new group under the TipCalc main group called &#8220;LogicTests&#8221;. This will look like a directory under your TipCalc application as shown here: </p>
<p><img src="http://blazingcloud.net/wp-content/TipCalcLogicTests.png" alt="TipCalcLogicTests" title="TipCalcLogicTests" width="319" height="286" class="alignnone size-full wp-image-467" /></p>
<p>Add a new file to the <strong>LogicTests</strong> group that is of type <strong>Objective-C test case class</strong> and call it &#8220;TipCalcTests.m&#8221;. Make sure the box is checked to create the associated header (.h) file, and select <em>only</em> the <strong>Logic Tests</strong> target to add the new file to. When you hit <strong>Finish</strong> the two new files will be added.</p>
<p>At this point you should try to run your tests. Make <strong>Logic Tests</strong> your active target  and click <strong>Build and Run</strong>. You won&#8217;t really see anything happen when you do this, but look in the lower right corner of your XCode window:</p>
<p><img src="http://blazingcloud.net/wp-content/XCodeErrorIcon.png" alt="XCodeErrorIcon" title="XCodeErrorIcon" width="139" height="85" class="alignnone size-full wp-image-476" /></p>
<p>Click on the red error icon to open up the build results window. The errors you see won&#8217;t really make any sense at this point, and I think its because they are generated during the run step and this target doesn&#8217;t have an executable to run. If you click <strong>Build</strong> instead of <strong>Build and Run</strong> you will get a more informative error. You don&#8217;t actually have to run anything because the tests are executed during the build step.</p>
<p>The new error should look like this:</p>
<p><img src="http://blazingcloud.net/wp-content/TipCalcBuild-Results.png" alt="TipCalcBuild Results" title="TipCalcBuild Results" width="800" height="326" class="alignnone size-full wp-image-482" /></p>
<p>This error is happening because when you create a new test case file by default it is set up to be an Application test, not a Logic test, so it expects to find an ApplicationDelegate instance, which is only present in the running app. You can remove the code that is for application testing from these test files, as you will make separate test files for those tests. In your header file remove these lines:</p>
<p></p><pre class="crayon-plain-tag">
//  Application unit tests contain unit test code that must be injected into an application to run correctly.
//  Define USE_APPLICATION_UNIT_TEST to 0 if the unit test code is designed to be linked into an independent test executable.

#define USE_APPLICATION_UNIT_TEST 1</pre><p></p>
<p>and these lines:</p>
<p></p><pre class="crayon-plain-tag">
#if USE_APPLICATION_UNIT_TEST
- (void) testAppDelegate;       // simple test on application
#else
- (void) testMath;              // simple standalone test
#endif</pre><p></p>
<p>so that you just have an empty header file. From the implementation file you can remove these lines:</p>
<p></p><pre class="crayon-plain-tag">
#if USE_APPLICATION_UNIT_TEST     // all code under test is in the iPhone Application

- (void) testAppDelegate {
    
    id yourApplicationDelegate = [[UIApplication sharedApplication] delegate];
    STAssertNotNil(yourApplicationDelegate, @&amp;quot;UIApplication failed to find the AppDelegate&amp;quot;);
    
}

#else                           // all code under test must be linked into the Unit Test bundle

- (void) testMath {
    
    STAssertTrue((1+1)==2, @&amp;quot;Compiler isn't feeling well today :-(&amp;quot; );
    
}
#endif</pre><p></p>
<p>so you have an empty implementation file. Now if you hit <strong>Build</strong> again you will not have any errors, and we can start writing some tests.</p>
<p>In the spirit of TDD we will write a test first before we write any other code. Add the following code to your implementation file:</p>
<p></p><pre class="crayon-plain-tag">
- (void) testTipCalculation {
    
    float percentage = .20;
    float bill = 34.45;
    float expectedTotal = percentage * bill;
    NSLog(@&amp;quot;expected total: %f&amp;quot;, expectedTotal);
    float result = [TipCalculator calculateTipFor:bill andPercentage:percentage];
    
    STAssertEquals(expectedTotal, result, @&amp;quot;Tip not calculated correctly. Expected %f but got %f&amp;quot;, expectedTotal, result);
}</pre><p></p>
<p>and the corresponding declaration in your header file:</p>
<p></p><pre class="crayon-plain-tag">
@interface TipCalcTests : SenTestCase {

}

- (void) testTipCalculation;

@end</pre><p></p>
<p>Build again and you will get a useful error: &#8220;&#8216;TipCalculator&#8217; undeclared (first use in this function)&#8221; because we haven&#8217;t defined the TipCalculator class. Add the TipCalculator class to the <strong>Classes</strong> group and add it to both the <strong>TipCalc</strong> and <strong>Logic Tests</strong> targets. Edit TipCalcTests.h and import TipCalculator.h like so:</p>
<p></p><pre class="crayon-plain-tag">
#import &amp;quot;TipCalculator.h&amp;quot;</pre><p> </p>
<p>Run your tests again and you will see the following results:</p>
<p><img src="http://blazingcloud.net/wp-content/TipCalcTestsBuild-Results1.png" alt="TipCalcTestsBuild Results1" title="TipCalcTestsBuild Results1" width="801" height="263" class="alignnone size-full wp-image-495" /></p>
<p>As you can see, the error message isn&#8217;t particularly helpful, but there is a warning that tells us &#8220;&#8216;TipCalculator&#8217; may not respond to &#8216;+calculateTipFor:andPercentage:&#8217;&#8221;</p>
<p>Add the method declaration now to your TipCalculator header:</p>
<p></p><pre class="crayon-plain-tag">
+ (float)calculateTipFor:(float)bill andPercentage:(float)percentage;</pre><p></p>
<p>and a stub for the method in your implementation file that returns a hard coded value:</p>
<p></p><pre class="crayon-plain-tag">
+ (float)calculateTipFor:(float)bill andPercentage:(float)percentage {
	return 0.8;
}</pre><p></p>
<p>Now when you build you will get a useful error telling you that your test failed:</p>
<p><img src="http://blazingcloud.net/wp-content/TipCalcTests-BuildResults2.png" alt="TipCalcTests BuildResults2" title="TipCalcTests BuildResults2" width="800" height="312" class="alignnone size-full wp-image-501" /></p>
<p>Notice that the only thing that it prints out is the error message you specifically told it to generate including the expected and actual values. So you will need to make sure your test results statements are meaningful.</p>
<p>If you run into issues it might be useful to log things to the console. In the sample code there is an NSLog statement:</p><pre class="crayon-plain-tag">
NSLog(@&amp;quot;expected total: %f&amp;quot;, expectedTotal);</pre><p></p>
<p>This output doesn&#8217;t get written to the run console in XCode (maybe because the tests are executed during the build step, not the run step?) but it does get written to the system console. You can find the system console by typing &#8220;console&#8221; into spotlight. The system console looks like this:</p>
<p><img src="http://blazingcloud.net/wp-content/ConsoleMessages.png" alt="ConsoleMessages" title="ConsoleMessages" width="691" height="205" class="alignnone size-full wp-image-517" /></p>
<p>A lot of messages get printed here, but if you filter the list by the string &#8220;otest&#8221; you will see your messages. If anyone knows how to get log output to show up in XCode please leave us a comment.</p>
<p>If you do want to launch your app in the simulator every time you run your tests you can just drag you <strong>TipCalc</strong> target into your <strong>Logic Tests</strong> target and click <strong>Build and Run</strong> instead of <strong>Build</strong>.</p>
<p>So that&#8217;s basically it, now you know how to write Logic Tests. You can find a complete list of test macro functions (like <strong>STAssertEquals</strong>) in the <a href="http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/905-A-Unit-Test_Result_Macro_Reference/unit-test_results.html#//apple_ref/doc/uid/TP40007959-CH21-SW2">Unit-Test Result Macro Reference</a> in the Apple site. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.blazingcloud.net/2010/02/20/test-driven-development-for-iphone/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
