tag:blogger.com,1999:blog-11019809252571233162024-02-02T13:45:49.681-08:00Cocoa TidbitsMacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.comBlogger59125tag:blogger.com,1999:blog-1101980925257123316.post-13267402832923362262013-10-15T03:29:00.001-07:002013-10-15T03:29:43.244-07:00Mobile Ads do not work (for app developers) In my humble opinion mobile ads just doesn' work for App developers as a mean to generate revenue from their apps.<br />
You have an average CTR of 0.21% , but you only get one cent or two cent per click. Meaning that you need millions of viewers per month to get a decent revenue.<br />
<br />
In my own experience I had an app with AdMob ads, and indeed I got a daily CTR of 0.17/0.2/0.22; much in line with the average CTR found.<br />
But I only had a few thousand visits per day, and that was strange because my app was downloaded much more.<br />
<br />
And than I came to conclusion that the only thing that prevented from ads to be shown, was AD BLOCKERS !<br />
<br />
And that my friends is why the mobile ads do not work ! More and more people install ad blockers on their devices and less and less ads are shown.<br />
<br />
<br />MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-54526601164343438772012-12-27T04:21:00.001-08:002012-12-27T04:21:03.641-08:00I'm participating in contest for the best mobile e-Gov app !<br />
<br />
Please vote for me: <span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px;"><b>http://tinyurl.com/cpn2rkm </b></span><br />
<span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px;"><b><br /></b></span>
<span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px;">Thank you in advance</span>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-423889359549357232012-08-18T02:52:00.002-07:002012-08-18T02:52:09.767-07:00My company website is onlineI finally found some time to setup my company website, you can have a look <a href="http://www.hvd-mobilesolutions.be/">here</a>.MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-48101113717441383112012-06-16T12:39:00.001-07:002012-06-16T12:39:14.145-07:00it has been ages...since I published something.<br />
But now I'm back, I was too busy with setting up my own business, start developing for iOS 5 and iPad, etc.<br />
So it was a very hectic 1 year and a half.<br />
I have now 8 apps on the appstore (and 1 under review) and my experiences are mixed , the free ones are very well downloaded , the payed however....<br />
It becomes more and more difficult to be found on the AppStore, I'm currently spending more time in marketing the apps via different social media than really developing and that's a shame I think.<br />
<br />
Anyway for those who want to know what my apps are here we go :<br />
<br />
<a href="http://itunes.apple.com/be/app/isignals/id328171880?l=nl&mt=8">iSignals for iPhone</a> , using CoreGraphics, financial integration with yahoo, PDF generation , email etc etc.<br />
<br />
<a href="http://itunes.apple.com/be/app/isignals-ng/id478576869?l=nl&mt=8">iSignals for iPad</a> , same as above is a port from the iPhone version for iOS 5 and higher<br />
<br />
<a href="http://itunes.apple.com/be/app/trackgenth/id530406004?l=nl&mt=8">TRACK</a> , is an app to follow an art exhibition in Ghent, using CoreLocation, Augmented reality, GPS functionality etc (for iPad)<br />
<br />
<a href="http://itunes.apple.com/be/app/equity-option-calculator/id359586036?l=nl&mt=8">Equity Option Calculator</a> , a professional option calculator for the iPhone<br />
<br />
The 4 other apps are for Belgium only and for specific purposes.<br />
<br />
Next time I'll discuss a bit more in depth on the different new technologies I used.<br />
<br />
PS: You can now also follow me on Twitter via @isignals1 or become friends on <a href="http://www.facebook.com/profile.php?id=100003905422163">Facebook</a>.MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-29261666117052963032010-08-05T10:03:00.000-07:002010-08-05T10:14:32.940-07:00NSNumberformatter for special currency formatsAnother day somebody asked me if it was possible with an NSNumberFormatter to format currency values like $1k , $1,02m etc.<div><br /></div><div>So instead of displaying a value like $1,020,000 to display it as $1,02m</div><div><br /></div><div>Now with a standard NSNumberFormatter its not possible, so you could create a custom formatter for that.</div><div><br /></div><div>The following code snippet will do the job</div><div><br /></div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo">- (<span style="color: #7e1ead">NSString</span> *) formatCurrencyValue: (<span style="color: #d200a5">double</span> )doubleValue </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo">{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7e1ead"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span></span>NSNumberFormatter<span style="color: #000000"> *nformat = [[</span>NSNumberFormatter<span style="color: #000000"> </span><span style="color: #470085">alloc</span><span style="color: #000000">] </span><span style="color: #470085">init</span><span style="color: #000000">];</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #470085"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span>[nformat </span>setFormatterBehavior<span style="color: #000000">:</span>NSNumberFormatterBehavior10_4<span style="color: #000000">];</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #470085"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span>[nformat </span>setCurrencySymbol<span style="color: #000000">:[[</span><span style="color: #7e1ead">NSLocale</span><span style="color: #000000"> </span>currentLocale<span style="color: #000000">] </span>objectForKey<span style="color: #000000">: </span><span style="color: #7e1ead">NSLocaleCurrencySymbol</span><span style="color: #000000">]];</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #470085"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span>[nformat </span>setNumberStyle<span style="color: #000000">:</span>NSNumberFormatterCurrencyStyle<span style="color: #000000">];</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #7e1ead">NSString</span> *stringValue = <span style="color: #d200a5">nil</span>;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #7e1ead">NSArray</span> *abbrevations = [<span style="color: #7e1ead">NSArray</span> <span style="color: #470085">arrayWithObjects</span>:<span style="color: #ea0008">@"k"</span>, <span style="color: #ea0008">@"m"</span>, <span style="color: #ea0008">@"b"</span>, <span style="color: #ea0008">@"t"</span>, <span style="color: #d200a5">nil</span>] ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #d200a5">for</span> (<span style="color: #7e1ead">NSString</span> *s <span style="color: #d200a5">in</span> abbrevations)</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>doubleValue /= <span style="color: #3700de">1000.0</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #d200a5">if</span> ( doubleValue < <span style="color: #3700de">1000.0</span> )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #d200a5">if</span> ( (<span style="color: #d200a5">long</span> <span style="color: #d200a5">long</span>)doubleValue % (<span style="color: #d200a5">long</span> <span style="color: #d200a5">long</span>) <span style="color: #3700de">100</span> == <span style="color: #3700de">0</span> )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #470085"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span>[nformat </span>setMaximumFractionDigits<span style="color: #000000">:</span><span style="color: #3700de">0</span><span style="color: #000000">];</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"> <span style="color: #d200a5">else</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #470085"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span>[nformat </span>setMaximumFractionDigits<span style="color: #000000">:</span><span style="color: #3700de">2</span><span style="color: #000000">];</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>stringValue = [<span style="color: #7e1ead">NSString</span> <span style="color: #470085">stringWithFormat</span>: <span style="color: #ea0008">@"%@%@"</span>, [nformat <span style="color: #470085">stringFromNumber</span>: [<span style="color: #7e1ead">NSNumber</span> <span style="color: #470085">numberWithDouble</span>: doubleValue]] , s] ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #d200a5">break</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>}<span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>} </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>[nformat <span style="color: #470085">release</span>] ; </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #470085">NSLog</span>(<span style="color: #ea0008">@"Value = %@"</span>, stringValue);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #d200a5">return</span> stringValue ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo">}</p></div><div><br /></div><div>Input :</div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #1a5b5e"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span>[</span><span style="color: #d200a5">self</span><span style="color: #000000"> </span>formatCurrencyValue<span style="color: #000000">: </span><span style="color: #3700de">1235.0f</span><span style="color: #000000">] ;</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #1a5b5e"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span>[</span><span style="color: #d200a5">self</span><span style="color: #000000"> </span>formatCurrencyValue<span style="color: #000000">: </span><span style="color: #3700de">10351.0f</span><span style="color: #000000">] ;</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #1a5b5e"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span>[</span><span style="color: #d200a5">self</span><span style="color: #000000"> </span>formatCurrencyValue<span style="color: #000000">: </span><span style="color: #3700de">100522.0f</span><span style="color: #000000">] ;</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #1a5b5e"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span>[</span><span style="color: #d200a5">self</span><span style="color: #000000"> </span>formatCurrencyValue<span style="color: #000000">: </span><span style="color: #3700de">1235111.0f</span><span style="color: #000000">] ;</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #1a5b5e"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span>[</span><span style="color: #d200a5">self</span><span style="color: #000000"> </span>formatCurrencyValue<span style="color: #000000">: </span><span style="color: #3700de">12351234.0f</span><span style="color: #000000">] ;</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #1a5b5e"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span>[</span><span style="color: #d200a5">self</span><span style="color: #000000"> </span>formatCurrencyValue<span style="color: #000000">: </span><span style="color: #3700de">192351234.0f</span><span style="color: #000000">] ;</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #1a5b5e"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span>[</span><span style="color: #d200a5">self</span><span style="color: #000000"> </span>formatCurrencyValue<span style="color: #000000">: </span><span style="color: #3700de">1872351234.0f</span><span style="color: #000000">] ;</span></p></div><div><span style="color: #000000">Output :</span></div><div><span style="color: #000000"><br /></span></div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><b>Value = £1.24k</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><b>Value = £10.35k</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><b>Value = £101k</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><b>Value = £1.24m</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><b>Value = £12.35m</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><b>Value = £192.35m</b></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><b>Value = £1.87b</b></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><b><br /></b></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><b>Note : you can add additional parameters to the function like number of fraction digits</b></p></div>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-66611069907587430152010-08-05T01:57:00.001-07:002012-06-26T06:05:08.034-07:00Telenet telemeter for iPhone/iPodThe telenet telemeter is now also available for the <a href="http://itunes.apple.com/be/app/itelemeter/id384334571?mt=8">iPhone</a> . Now also available for <a href="http://itunes.apple.com/be/app/telemeter-hd/id536837237?l=nl&mt=8">iPad</a><br />
<div>
Some screenshots :</div>
<div>
<br /></div>
<div>
<img alt="" border="0" id="BLOGGER_PHOTO_ID_5501847848116020338" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5AuHNPQDVlzmzMbKrQQvOOZMguv0PmvN719Jxl6Puqu75E2zX71XWOq2mWUrQvrIy4i27ozH6Ml7Ch7Y7zJpX3sNiI6JCDNYZ7VsxVzDYpDcvXdiyTstKbb1JbHrq7ExmKFiNYjD7gu4/s320/Screenshot+2010.07.25+13.48.59.png" style="cursor: hand; height: 320px; width: 214px;" /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
(Image below is from version 1.1, supports turbonet and fibernet)</div>
<div>
<br /></div>
<div>
<img alt="" border="0" id="BLOGGER_PHOTO_ID_5501848047639032002" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkPIls53zjqovI4a9FFuLfkUtkhW80vWxf7O2nfjNvyulKmpeYstLJesrmmdR_vrlpv2DGB2azqHJwYdMeNNizcoCN0mNoUzKCMdw0ZRRbrg9SLMocq18iArBRH15WaNkJazM8C0Vc2rQ/s320/Screenshot+2010.08.04+13.33.53.png" style="cursor: hand; height: 320px; width: 214px;" /></div>
<div>
</div>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com1tag:blogger.com,1999:blog-1101980925257123316.post-50005365403672454092010-07-31T03:00:00.000-07:002010-08-05T02:29:19.816-07:00Drawing text on a pie chart (Cocoa)Drawing text along side a pie chart (see image below) is fairly simple :<div><br /><div><img style="cursor:pointer; cursor:hand;width: 320px; height: 120px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg48tUXZvso2BOAS9dOvcYkkC3tCRGZdk_otkPJ6i5z9_Boo05BJLtyxuPhkk5s2qxDFelYOo9IqBrHeR0gEUYsEmE1OdzUeubz6BihnNa757pVIXLgPXiuPSYAypzU2fspb5SD_FTRZvw/s320/Schermafbeelding+2010-07-31+om+12.01.47.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5500008700242436418" /></div></div><div><br /></div><div>You only need a bit of math.</div><div><br /></div><div>Let's look a some code :</div><div><br /></div><div>First you have your text :</div><div><br /></div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color:#7e1ead;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>NSDictionary<span style="color:#000000;"> *attributes = [</span>NSDictionary<span style="color:#000000;"> </span><span style="color:#470085;">dictionaryWithObjectsAndKeys</span><span style="color:#000000;">:[</span>NSFont<span style="color:#000000;"> </span><span style="color:#470085;">fontWithName</span><span style="color:#000000;">:</span><span style="color:#ea0008;">@"Helvetica"</span><span style="color:#000000;"> </span><span style="color:#470085;">size</span><span style="color:#000000;">:</span><span style="color:#3700de;">12</span><span style="color:#000000;">], </span>NSFontAttributeName<span style="color:#000000;">,[</span>NSColor<span style="color:#000000;"> </span><span style="color:#470085;">blackColor</span><span style="color:#000000;">], </span>NSForegroundColorAttributeName<span style="color:#000000;">, </span><span style="color:#d200a5;">nil</span><span style="color:#000000;">];</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#7e1ead;">NSAttributedString</span> * currentText=[[<span style="color:#7e1ead;">NSAttributedString</span> <span style="color:#470085;">alloc</span>] <span style="color:#470085;">initWithString</span>: @"some text" <span style="color:#470085;">attributes</span>: attributes];</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><br /></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family:'times new roman';"><span class="Apple-style-span" style="font-size:medium;">Then you need to figure out where you will put the text :</span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family:'times new roman';"><span class="Apple-style-span" style="font-size:medium;"></span></span></p><span class="Apple-style-span" style="font-family:'times new roman';"><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>dot = <span style="color:#470085;">NSMakePoint</span>( size_x/<span style="color:#3700de;">2</span> + <span style="color:#470085;">cos</span> (<span style="color:#824526;">PI</span> * mid_angle / <span style="color:#3700de;">180</span> ) * <span style="color:#3700de;">50</span> , size_y/<span style="color:#3700de;">2</span> + <span style="color:#470085;">sin</span> ( <span style="color:#824526;">PI</span> * mid_angle / <span style="color:#3700de;">180</span> ) * <span style="color:#3700de;">50</span> ) ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color:#470085;"><span style="color:#000000;"> <span class="Apple-tab-span" style="white-space:pre"> </span>[greenPath </span>appendBezierPathWithArcWithCenter<span style="color:#000000;">: dot </span>radius<span style="color:#000000;">: </span><span style="color:#3700de;">2</span><span style="color:#000000;"> </span>startAngle<span style="color:#000000;">: </span><span style="color:#3700de;">0</span><span style="color:#000000;"> </span>endAngle<span style="color:#000000;">: </span><span style="color:#3700de;">360</span><span style="color:#000000;"> ] ; </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p><div><span class="Apple-tab-span" style="white-space:pre"><br /></span></div></span><p></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family:'times new roman';"><span class="Apple-style-span" style=" ;font-size:medium;">(This is the dot you see in the picture above)</span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family:'times new roman';"><span class="Apple-style-span" style=" ;font-size:medium;"><br /></span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family:'times new roman';"><span class="Apple-style-span" style=" ;font-size:medium;">The mid_angle is the angle of slice divided by 2.</span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family:'times new roman';"><span class="Apple-style-span" style=" ;font-size:medium;"><br /></span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family:'times new roman';"><span class="Apple-style-span" style=" ;font-size:medium;">Then you draw the text :</span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family:'times new roman';"><span class="Apple-style-span" style=" ;font-size:medium;"></span></span></p><span class="Apple-style-span" style="font-family:'times new roman';"><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"> </p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"> textStartPoint = <span style="color:#1a5b5e;">makeTextStartingPoint</span>( [currentText <span style="color:#470085;">size</span>], bounds , mid_angle, <span style="color:#3700de;">50</span> ) ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>[currentText <span style="color:#470085;">drawAtPoint</span>:textStartPoint];</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"> <span class="Apple-tab-span" style="white-space:pre"> </span></p></span><p></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family:'times new roman';"><span class="Apple-style-span" style="font-size:medium;"><br /></span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family:'times new roman';"><span class="Apple-style-span" style="font-size:medium;">The function makeTextStartingPoint looks like follows :</span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family:'times new roman';"><span class="Apple-style-span" style="font-size:medium;"><br /></span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family:'times new roman';"><span class="Apple-style-span" style="font-size:medium;"></span></span></p><span class="Apple-style-span" style="font-family:'times new roman';"><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo">NSPoint makeTextStartingPoint( <span style="color:#7e1ead;">NSSize</span> textSize, <span style="color:#7e1ead;">NSRect</span> bounds , <span style="color:#d200a5;">float</span> angle, <span style="color:#d200a5;">int</span> offset )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo">{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#7e1ead;">NSPoint</span> textStartPoint ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#d200a5;">float</span> size_x = bounds.<span style="color:#7e1ead;">size</span>.<span style="color:#7e1ead;">width</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#d200a5;">float</span> size_y = bounds.<span style="color:#7e1ead;">size</span>.<span style="color:#7e1ead;">height</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#d200a5;">float</span> angle_radian = <span style="color:#824526;">PI</span> * angle / <span style="color:#3700de;">180</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#d200a5;">if</span> ( angle <= <span style="color:#3700de;">90</span> )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>textStartPoint = <span style="color:#470085;">NSMakePoint</span>( size_x/<span style="color:#3700de;">2</span> + <span style="color:#470085;">cos</span> (angle_radian) * offset + <span style="color:#3700de;">5</span> , size_y/<span style="color:#3700de;">2</span> + <span style="color:#470085;">sin</span> (angle_radian ) * offset ) ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#d200a5;">if</span> ( angle > <span style="color:#3700de;">90</span> && angle <= <span style="color:#3700de;">180</span>)</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>textStartPoint = <span style="color:#470085;">NSMakePoint</span>( size_x/<span style="color:#3700de;">2</span> + <span style="color:#470085;">cos</span> ( angle_radian ) * offset - textSize.<span style="color:#7e1ead;">width</span> - <span style="color:#3700de;">5</span> , size_y/<span style="color:#3700de;">2</span> + <span style="color:#470085;">sin</span> (angle_radian ) * offset ) ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#d200a5;">if</span> ( angle > <span style="color:#3700de;">180</span> && angle <= <span style="color:#3700de;">270</span> )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>textStartPoint = <span style="color:#470085;">NSMakePoint</span>( size_x/<span style="color:#3700de;">2</span> + <span style="color:#470085;">cos</span> ( angle_radian ) * offset - textSize.<span style="color:#7e1ead;">width</span> - <span style="color:#3700de;">5</span>, size_y/<span style="color:#3700de;">2</span> + <span style="color:#470085;">sin</span> ( angle_radian ) * offset - textSize.<span style="color:#7e1ead;">height</span> ) ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#d200a5;">if</span> ( angle > <span style="color:#3700de;">270</span> )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>textStartPoint = <span style="color:#470085;">NSMakePoint</span>( size_x/<span style="color:#3700de;">2</span> + <span style="color:#470085;">cos</span> ( angle_radian ) * offset + <span style="color:#3700de;">8</span> , size_y/<span style="color:#3700de;">2</span> + <span style="color:#470085;">sin</span> (angle_radian ) * offset - textSize.<span style="color:#7e1ead;">height</span> ) ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#d200a5;">return</span> textStartPoint ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo">}</p><div><br /></div></span><p></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family:'times new roman';"><span class="Apple-style-span" style=" ;font-size:medium;">The reason I use an attributed string is because now I get the length of the text in pixels. You also see that the starting point is different from quadrant to quadrant.</span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family:'times new roman';"><span class="Apple-style-span" style=" ;font-size:medium;"><br /></span></span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p></div>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-60869511377863082552010-06-21T08:35:00.000-07:002010-08-05T02:27:19.756-07:00iSignals v2.0.2<span class="Apple-style-span" style="font-size:medium;"><div><span class="Apple-style-span" style="font-size:medium;">Version 2.0.2 of iSignals is finally landed !</span></div><br /></span><div><span class="Apple-style-span" style="font-size:medium;">It's now compatible with iOS4, contains a subscription store, contains a lot of technical analysis charts etc.</span></div><div><br /></div><div>It still has the possibility to follow more than 17000 instruments on 28 markets. You can receive buy/sell signals (with paid subscription) but you can do your own technical analysis.</div><div><br /></div><div>The application supports MACD, MFI, EMA, SMA,TMA, Parabolic SAR, Bollingerbands,ROC, RSI, Slow and fast stochastic, Williams %R and the Chaikin Osscilator?</div><div><br /></div><div><span class="Apple-style-span" style="font-size:medium;">Some screenshots :</span></div><div><span class="Apple-style-span" style="font-size:medium;"><br /></span></div><div><span class="Apple-style-span" style="font-size:medium;"><br /></span></div><div><span class="Apple-style-span" style="font-size:medium;"><img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFrwxj7w6y7Dkfefum38ehBUtYycMAuUTqXMdk28BqBk7gQ3q5_gjlQTfWMeG0MlLPxEvTGWQhHVKZ17OChBXN86Z3KOG7GCLu6rdWLVWZSqUYPWLK3iM61rhPPBiYdk73KwBsac_1owE/s320/Screenshot+2009.12.14+21.11.51.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5501853522420315458" /></span><img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSm9WJQhiJ9WnKONAt3ZrCzE7UllZOApdEdmN6j9lMYUUFRt0RFi29UT71PGtH8GxFkU2jCNTj1SjYf6WVTDugRYnYgtEiVh1v5r7Z1Pbwx-70CYgnulqXN_chZCLuNlasjJZs_hyphenhyphenHAh4/s320/Screenshot+2009.12.18+10.06.03.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5501853534363146338" /><img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinue45r2uf4jy9wdwHPbM9On96dQBO1FXjRAxklsECW4uFcUjVcaD7f6f6FDC-pCQTBx5C9IKLHOQkuvqZNCIoJkNP_8aTDu7bH5DGW9BVFmpVsqxlhK4DytAxhuJ9lXSUZPcEy4-wwHI/s320/Screenshot+2009.12.14+21.12.40.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5501853524140444466" /><img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2e1GWoGVCYT9V816DzgtoDFFFoelUUU5-TmrhueXIOBDRMXhV8f_HtQFQjTM7AZrxQg4tTqkESrGdLPlN1T3Y3M5krs9DbTdojqoQOFhaRmaWL9MxkVOYHIFOWHWGD-ts7HxCqScrhv8/s320/Screenshot+2010.06.13+12.57.25.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5501853530092219490" /></div><div><span class="Apple-style-span" style="font-size:medium;"></span></div><div><br /></div><div><br /></div><div><br /></div><div><span class="Apple-style-span" style="font-size:medium;">Have look : </span><span class="Apple-style-span" style="font-family:Arial;"><span class="Apple-style-span" style="font-size:medium;">URL : </span><a href="http://itunes.apple.com/us/app/isignals/id328171880?mt=8"><span style="text-decoration: underline"><span class="Apple-style-span" style="font-size:medium;">http://itunes.apple.com/us/app/isignals/id328171880?mt=8</span></span></a></span></div> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Times New Roman'; min-height: 15.0px"><span class="Apple-style-span" style="font-size:medium;"><br /></span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Arial; color:#110097;"><span class="Apple-style-span" style="font-family:'Times New Roman';"><span class="Apple-style-span" style="font-family:Arial;"><span class="Apple-style-span" style="font-size:medium;">Instruction video of iSignals : </span></span></span><a href="http://www.youtube.com/watch?v=fd9nrEr-r7E"><span style="text-decoration: underline; "><span class="Apple-style-span" style="font-size:medium;">http://www.youtube.com/watch?v=fd9nrEr-r7E</span></span></a></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Arial; color:#110097;"><span class="Apple-style-span" style="font-family:'Times New Roman';"><span class="Apple-style-span" style="font-family:Arial;"><br /></span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Arial; color:#110097;"><span class="Apple-style-span" style="font-family:'Times New Roman';"><span class="Apple-style-span" style="font-family:Arial;"><br /></span></span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Times New Roman'; min-height: 15.0px"><br /></p>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-87467707465192426822010-01-15T06:47:00.000-08:002010-01-18T00:36:39.751-08:00a UISegmentedControl subclass that simulates checkboxesI would like to share a small , possible, implementation of checkboxes on the iPhone using a UISegmentedControl subclass.<div><br /></div><div>The UISegmentedControl is in fact a radiobutton over multiple possibilities, now in certain circumstances it could be usefull that you can select multiple items.</div><div>One possibility is to use a tableview, however in some cases this is overkill.</div><div><br /></div><div>Suppose you have the following selection list :</div><div style="text-align: center;"><br /></div><div><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 208px; height: 39px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi42lODYYC_idIpWejgeclD2pQ9qnuH7OY6aS91kk_jOYV1P6YaIZiXBBOdyZvcvH97yTbkM8RHMXgce8gBDYr_AvvwV77uZnSYjRufaJChgL7H1emV7xF4WkncbDHO-439u5ucsUVqGH0/s320/Afbeelding+1.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5426979879939811090" /></div><div>In this list you want to be able to select multiple values like this (for example) :</div><div><br /></div><div><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 210px; height: 44px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga8TbybnhnteuW0Dz7g7Raz5MwZ_BA8VveCvcB_SPFEDgsb5PuJZjS3FqHTa4xar6C_5Dk1NyAN_KL7JDhf5gHXFjYfsbplUKpmw76HwVf_CVSzaJlXk99D2wp86flMhiQQf_FN6Hvytw/s320/Afbeelding+2.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5426980204565272914" /></div><div>Now to be able to do this , I wrote a small subclass of UISegmentedControl :</div><div><br /></div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"><span style="color:#643820;">#import </span><uikit/uikit.h></uikit/uikit.h></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">@interface</span> UIMultipleSelectionSegmentControl : UISegmentedControl {</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#5c2699;">NSMutableSet</span> *indices ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"> </span>@property<span style="color:#000000;">( </span>nonatomic<span style="color:#000000;">,</span>retain<span style="color:#000000;">) </span><span style="color:#5c2699;">NSMutableSet</span><span style="color:#000000;"> *indices ;</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"> </p> <p color="#aa0d91" style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; ">@end</p><p color="#aa0d91" style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; "><br /></p><p color="#aa0d91" style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; "><br /></p></div><div>Now the trick is that you cannot use the private variables of the UISegmentedControl class, so the only possibility that one can use is to override the setSelectedSegmentIndex: and their do the actual implementation of multiple selections .</div><div><br /></div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"><span style="color:#643820;">#import </span>"UIMultipleSelectionSegmentControl.h"</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color:#aa0d91;">@implementation</span> UIMultipleSelectionSegmentControl</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"> </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91">@synthesize<span style="color:#000000;"> indices ;</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"> </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"> </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#5c2699;">NSSet</span> *) selectedSegmentIndices</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>return<span style="color:#000000;"> </span>self<span style="color:#000000;">.</span><span style="color:#3f6e74;">indices</span><span style="color:#000000;"> ;</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#aa0d91;">void</span>) setSelectedSegmentIndices: (<span style="color:#5c2699;">NSSet</span> *) aSet</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#5c2699;">NSEnumerator</span> *enumerator = [aSet <span style="color:#2e0d6e;">objectEnumerator</span>];</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#5c2699;">NSNumber</span> *value;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">while</span> ((value = [enumerator <span style="color:#2e0d6e;">nextObject</span>])) </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span>[</span><span style="color:#aa0d91;">self</span><span style="color:#000000;"> </span>setSelectedSegmentIndex<span style="color:#000000;">: [value </span>integerValue<span style="color:#000000;">]] ;</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span> </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#aa0d91;">void</span>) setSelectedSegmentIndex: (<span style="color:#5c2699;">NSInteger</span>) anIndex</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span> </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">if</span> ( <span style="color:#aa0d91;">self</span>.indices == <span style="color:#aa0d91;">nil</span> ) <span style="color:#aa0d91;">self</span>.indices = [<span style="color:#5c2699;">NSMutableSet</span> <span style="color:#2e0d6e;">set</span>] ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span> </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">if</span> ( anIndex >= <span style="color:#1c00cf;">0</span> )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#5c2699;">NSNumber</span> *indexNumber ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#5c2699;">UIImage</span> *myImage ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>indexNumber = [<span style="color:#5c2699;">NSNumber</span> <span style="color:#2e0d6e;">numberWithInt</span>: anIndex] ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span> </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">if</span> ( ! [<span style="color:#aa0d91;">self</span>.indices <span style="color:#2e0d6e;">containsObject</span>: indexNumber] )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>[<span style="color:#aa0d91;">self</span>.indices <span style="color:#2e0d6e;">addObject</span>: indexNumber] ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">switch</span>( anIndex )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">0</span> :myImage = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>: <span style="color:#c41a16;">@"segment-5-sel.png"</span>] ; <span style="color:#aa0d91;">break</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">1</span> :myImage = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>: <span style="color:#c41a16;">@"segment-10-sel.png"</span>] ; <span style="color:#aa0d91;">break</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">2</span> :myImage = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>: <span style="color:#c41a16;">@"segment-20-sel.png"</span>] ; <span style="color:#aa0d91;">break</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">3</span> :myImage = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>: <span style="color:#c41a16;">@"segment-50-sel.png"</span>] ; <span style="color:#aa0d91;">break</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">4</span> :myImage = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>: <span style="color:#c41a16;">@"segment-100-sel.png"</span>] ; <span style="color:#aa0d91;">break</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">5</span>: myImage = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>: <span style="color:#c41a16;">@"segment-200-sel.png"</span>] ; <span style="color:#aa0d91;">break</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span>[</span><span style="color:#aa0d91;">super</span><span style="color:#000000;"> </span>setSelectedSegmentIndex<span style="color:#000000;">: anIndex] ;</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>else</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space: pre; "> </span> [<span style="color:#aa0d91;">self</span>.indices <span style="color:#2e0d6e;">removeObject</span>: indexNumber] ;<br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span>[</span><span style="color:#aa0d91;">super</span><span style="color:#000000;"> </span>setSelectedSegmentIndex<span style="color:#000000;">: -</span><span><span class="Apple-style-span" style="color: rgb(28, 0, 207);">indexNumber</span></span><span style="color:#000000;">] ;</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">switch</span>( anIndex )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">0</span> :myImage = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>: <span style="color:#c41a16;">@"segment-5.png"</span>] ; <span style="color:#aa0d91;">break</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">1</span> :myImage = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>: <span style="color:#c41a16;">@"segment-10.png"</span>] ; <span style="color:#aa0d91;">break</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">2</span> :myImage = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>: <span style="color:#c41a16;">@"segment-20.png"</span>] ; <span style="color:#aa0d91;">break</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">3</span> :myImage = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>: <span style="color:#c41a16;">@"segment-50.png"</span>] ; <span style="color:#aa0d91;">break</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">4</span> :myImage = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>: <span style="color:#c41a16;">@"segment-100.png"</span>] ; <span style="color:#aa0d91;">break</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">case</span> <span style="color:#1c00cf;">5</span>: myImage = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>: <span style="color:#c41a16;">@"segment-200.png"</span>] ; <span style="color:#aa0d91;">break</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>[<span style="color:#aa0d91;">self</span> <span style="color:#2e0d6e;">setImage</span>: myImage <span style="color:#2e0d6e;">forSegmentAtIndex</span>: anIndex] ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span> </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"> }</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#aa0d91;">void</span>)dealloc {</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"> [indices <span style="color:#2e0d6e;">release</span>] ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"> [<span style="color:#aa0d91;">super</span> <span style="color:#2e0d6e;">dealloc</span>];</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91">@end</p><div><span class="Apple-style-span" style="color: rgb(170, 13, 145); font-family:Monaco;font-size:10px;"><br /></span></div></div><div><br /></div><div>In this case I made images of each segment, one that represent the unselected image and one the represent the selected image.</div><div>(the images in my case are 24x24 pixels in size).</div><div><br /></div><div>This subclass will still send UIControlChangeEvents, so it acts as a normal UIControl class.</div><div>To get the indices you have to call the method selectedSegmentIndices and to set them you use setSelectedSegmentIndices:.</div><div>(note that the indices are a NSSet).</div><div><br /></div><div><br /></div><div> </div><div><br /></div><div style="text-align: center;"><br /></div><div style="text-align: center;"><br /></div><div><br /></div><div><br /></div><div><br /></div>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com6tag:blogger.com,1999:blog-1101980925257123316.post-69807137346272120292009-12-27T04:41:00.000-08:002009-12-27T05:54:43.129-08:00Apple's AppStore a goldmine or ...You find a lot of blogs on the Internet which speculates how good (or bad) sales are on the AppStore. Usually from people who didn't publish an application themselfs on the AppStore.<div><br /></div><div>Now here I'm gone write my personal experience with the AppStore. About 1 month ago (3th of December) my application was finally approved by Apple.</div><div>Let's go over the timeline from concept of the app until today.</div><div><br /></div><div><span class="Apple-style-span" style="font-weight: bold;"><span class="Apple-style-span" style="font-size:x-large;">1. Concept</span></span></div><div><br /></div><div>The idea came after a discussion with a friend , who's a financial analyst, to build a front end on top of his trading engine.</div><div>So the idea was that I should build an iPhone front end and that he would build the web infrastructure so that the iPhone could communicate with the trading engine.</div><div>I also did some investigation and I saw that their where only 1000 apps on the AppStore in the finance category , so at least we would be seen.</div><div><br /></div><div>Of course this was not a game so we wouldn't reach the masses or getting great attention from review sites etc.</div><div><br /></div><div>(Note: I still find it strange that people buy 600 USdollars phones to play games on it, but oke).</div><div><br /></div><div><span class="Apple-style-span" style="font-size:x-large;"><span class="Apple-style-span" style="font-weight: bold;">2. Development</span></span></div><div><br /></div><div>And then it was April 2009, we started the development. I bought a development license from Apple for 99 USdollar ( 79 euro), got myself an iPod Touch for development. Got all the contracts signed (that was smooth by the way) and got myself an IRS number.</div><div>That was a strange experience for a non-US citizen ;-).</div><div><br /></div><div>Apparently they don't believe in the Internet because the only to get that number was by phone, mail or fax - no online -.</div><div><br /></div><div>Anyway we start coding , he was using PHP for the backend and I using Objective-C for the front-end.</div><div><br /></div><div>And the communication between iPod and backend happened via HTTP using CSV files (nope no XML , that's overkill, the CSV's are generated on the fly during a request).</div><div><br /></div><div>It took about 2,5 months to develop it, 1 month beta-testing and 1 month for corrections, change requests etc.</div><div>So in August 2009 I submitted the app for approval to ItunesConnect. And now the story begins...</div><div><br /></div><div><span class="Apple-style-span" style="font-size:x-large;"><span class="Apple-style-span" style="font-weight: bold;">3. Approval process</span></span></div><div><br /></div><div>According to Apple it takes about 14 days to get approval (or rejection). So I was thinking , I submit it in August then we have an availability date of September 1th.</div><div><br /></div><div>Now that was wrong.</div><div><br /></div><div>After a week I got a mail from Apple to say that it would take longer to approve. But with no further explanation for what reason.</div><div>So august went by -> no approval</div><div>September went by -> no approval (and no message from Apple)</div><div>October went by -> no approval (no message from Apple).</div><div><br /></div><div>At that time I sent an email to them but I got a standard response back.</div><div><br /></div><div>And then suddenly in November they started the review of the application and I got an email that the app was rejected because of an usability problem.</div><div>I quickly fixed it and resubmitted it, and I was afraid that it would take again 3,5 months for approval.</div><div><br /></div><div>But luckily for one reason or another they almost immediatly reviewed it and approved it.</div><div>So since December 3th the application is on the AppStore for sale !</div><div><br /></div><div><span class="Apple-style-span" style="font-size:x-large;"><span class="Apple-style-span" style="font-weight: bold;">4. Post Natal depression</span></span></div><div><br /></div><div>So the new born is 1 month old, and how is the sales going ?</div><div><br /></div><div>Well to be honest, not so good (sold twenty-some). We knew it was a niche market so we didn't expect 1000 downloads per day. But a bit more than 20... would be nice.</div><div><br /></div><div>Now the AppStore (and ITunes Connect) doesn't give us much help. With more than 100.000 applications available you are just 1 item in a giant catalog (even finance has 1700 apps).</div><div>And a catalog with very limited search and browse facilities , after a few days your application is somewhere on page 10 and nobody cares anymore.</div><div><br /></div><div>ITunes Connect as marketing aid is also nothing, you can enter keywords but you have no idea how many people are landing on your app, which keywords they used etc etc. You only see how many downloads their are.</div><div><br /></div><div>Now we are spending our time in sending emails to review sites etc. But those guys are also overwhelmed with requests. And most likey they rather like to review games or entertainment apps than boring financial app's.</div><div><br /></div><div><br /></div><div>Conclusion : creating and developing an application for the iPhone is the easy part , its 10 % of the effort , marketing is the other 90%.</div><div><br /></div><div>For those who think that the AppStore is a goldmine , forget it, a good idea is a prerequisite but some luck and a lot of marketing is needed. And even then you are not sure that you'll win the jackpot. </div><div><br /></div><div> </div><div><br /></div>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-75407928991055395472009-12-26T06:51:00.000-08:002010-01-11T06:31:05.002-08:00drawing graphics for the iPhone (not opengl ES)Don't we all want to make graphics like this : ?<div><br /></div><div style="text-align: center;"><br /></div><div><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 176px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2bYJ5ip4PXbMkCzEm7cqCJ1ydQsKC0vFacQFefgIzGOpmpP72g0VyIfYPkp4YERoL7Dd-5aWz99POVVT8vCRqTIlsFjdxj7my_b8IsZzqLE9whnJlF7GvAn-UZ0W2JrePurxPAlmGpCE/s320/Afbeelding+12.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5419558321996541890" /></div><div style="text-align: center;"><br /></div><div style="text-align: left;">Well , I'll try to explain how I did this (BTW this graphics comes from my iphone application <a href="http://itunes.apple.com/be/app/isignals/id328171880?mt=8">iSignals)</a>.</div><div style="text-align: left;"><br /></div><div style="text-align: left;">First create a file in your project which is a subclass of UIView (via XCode>File>New File). Call it for example MyGraphView. </div><div style="text-align: left;"><br /></div><div style="text-align: left;">Then you create a XIB with Interface Builder , in the XIB you add a view and you change the class identity to the custom view class MyGraphView.</div><div style="text-align: left;"><br /></div><div style="text-align: left;">And now comes the coding part, lets for the sake of clarity say that you have 2 arrays in MyGraphView (usually you'll pass them via a controller class). These arrays are called datapoints[] and ylabels[].</div><div style="text-align: left;"><br /></div><div style="text-align: left;">So let's see how the drawRect method is implemented.</div><div style="text-align: left;"><br /></div><div style="text-align: left;"><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">- (<span style="color:#aa0d91;">void</span>)drawRect:(<span style="color:#5c2699;">CGRect</span>)rect {</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"><span style="color:#000000;"> </span>// Drawing code</p><div><span class="Apple-style-span" style="color: rgb(0, 116, 0); font-family:Monaco;font-size:10px;"><br /></span></div></div><div style="text-align: left;"><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">float</span> width = rect.<span style="color:#5c2699;">size</span>.<span style="color:#5c2699;">width</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">float</span> height = rect.<span style="color:#5c2699;">size</span>.<span style="color:#5c2699;">height</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#5c2699;">CGContextRef</span> currentContext ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">int</span> i = <span style="color:#1c00cf;">0</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span> </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span> <span class="Apple-style-span" style="color: rgb(0, 116, 0); ">// Get the graphics context that we are currently executing under</span></span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span>currentContext = </span>UIGraphicsGetCurrentContext<span style="color:#000000;">() ;</span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0);"></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"><span style="color:#000000;"> ;</span></p><p></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0);"><br /></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="font-family: 'times new roman'; font-size: 48px;"> </span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;"><br /></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;">In the first lines of the drawRect, I save the width and the height, I'll use this to calculate the scale factors.</span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;">To understand this you need to know a bit of coordinatesystems. The iPhone coordinates are simply the pixels that can be drawn. So for example a view can be 200 px wide and 300 px high.</span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;">But of course what more important is , is the world coordinatessystem. And these coordinates are the coordinates of your world.</span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;">For example if I want to plot 600 points and the range of those points are between 0.5 and 3.5 then my user coordinatessystem is: X-axis =(0,600) Y-axis = (0.5,3.5).</span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;"><br /></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;">So to convert user points into iphone points (or view points) I need to apply a scale factor. The scale factor is calculated as follows.</span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;"><br /></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;"></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#643820;">#define OFFSET_X <span style="color:#1c00cf;">30.0f</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#643820;">#define OFFSET_Y <span style="color:#1c00cf;">10.0f</span> </p><div><span class="Apple-style-span" style="color: rgb(100, 56, 32); font-family:Monaco;font-size:10px;"><br /></span></div><p></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;"></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#3f6e74;">scale_factor_x</span> = ( width - <span style="color:#643820;">OFFSET_X</span> ) / ( [<span style="color:#3f6e74;">dataPoints</span> <span style="color:#2e0d6e;">count</span>] - <span style="color:#1c00cf;">0</span> );</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#3f6e74;">scale_factor_y</span> = (height - <span style="color:#643820;">OFFSET_Y</span> ) / (<span style="color:#3f6e74;">max_y</span> - <span style="color:#3f6e74;">min_y</span> ) ; // max_y = max(dataPoints) ;min_y = min(dataPoints)<span class="Apple-tab-span" style="white-space:pre"> </span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><br /></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-style-span" style=" ;font-family:'times new roman';font-size:large;">Note: OFFSET_X and OFFSET_Y are 2 constants to let some space in the view where I can are plot the axes and labels of the axes.</span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-style-span" style=" ;font-family:'times new roman';font-size:18px;"><br /></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-style-span" style=" ;font-family:'times new roman';font-size:18px;">So let's draw the axes , please note that in this first version I don't use CGPath's , later I'll refactor the code and use CGPath's.</span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-style-span" style=" ;font-family:'times new roman';font-size:18px;">And also be aware that I use the default orientation and default location of the origin of the view ( point (0,0) is in the upper left corner).</span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-style-span" style=" ;font-family:'times new roman';font-size:18px;"><br /></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-style-span" style=" ;font-family:'times new roman';font-size:18px;"></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>// draw the axes</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextSetRGBStrokeColor</span>(currentContext, <span style="color:#1c00cf;">0.83</span>, <span style="color:#1c00cf;">0.83</span>, <span style="color:#1c00cf;">0.83</span>, <span style="color:#1c00cf;">0.7</span>); // this is sort of gray</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextMoveToPoint</span>( currentContext, <span style="color:#643820;">OFFSET_X</span>, height - <span style="color:#643820;">OFFSET_Y</span> );</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextAddLineToPoint</span>( currentContext, <span style="color:#643820;">OFFSET_X</span>, <span style="color:#643820;">OFFSET_Y</span> );</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextMoveToPoint</span>( currentContext, <span style="color:#643820;">OFFSET_X</span>, height - <span style="color:#643820;">OFFSET_Y</span> );</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextAddLineToPoint</span>( currentContext, width, height - <span style="color:#643820;">OFFSET_Y</span> );</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>CGContextStrokePath<span style="color:#000000;">(currentContext);</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-style-span" style="color: rgb(46, 13, 110);"> </span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0);"><br /></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0);"><span class="Apple-style-span" style=" ;font-family:'times new roman';font-size:large;">And draw some gridlines</span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;"><br /></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;"></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"> </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextSetRGBStrokeColor</span>(currentContext, <span style="color:#1c00cf;">0.83</span>, <span style="color:#1c00cf;">0.83</span>, <span style="color:#1c00cf;">0.83</span>, <span style="color:#1c00cf;">1</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#5c2699;">CGFloat</span> len[] = {<span style="color:#1c00cf;">4</span>,<span style="color:#1c00cf;">2</span>} ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextSetLineDash</span>( currentContext, <span style="color:#1c00cf;">0</span>, len, <span style="color:#1c00cf;">2</span> ) ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"> <span style="color:#aa0d91;">for</span> ( i = <span style="color:#643820;">OFFSET_X</span> ; i <= height ; i = i + <span style="color:#643820;">OFFSET_X</span> )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextMoveToPoint</span>( currentContext, <span style="color:#643820;">OFFSET_X</span>, height - <span style="color:#643820;">OFFSET_Y</span> - i );</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextAddLineToPoint</span>( currentContext, width, height - <span style="color:#643820;">OFFSET_Y</span> - i);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>CGContextStrokePath<span style="color:#000000;">(currentContext);</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-style-span" style="color: rgb(46, 13, 110);"> </span></p><p></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;">And then draw the graph of datapoints</span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;"><br /></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;"></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"> </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextSetRGBStrokeColor</span>(currentContext, <span style="color:#1c00cf;">1.0</span>, <span style="color:#1c00cf;">0.65</span>, <span style="color:#1c00cf;">0</span>, <span style="color:#1c00cf;">1</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"> <span style="color:#5c2699;">UIImage</span> *red = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>: <span style="color:#c41a16;">@"red.png"</span>] ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#5c2699;">UIImage</span> *green = [<span style="color:#5c2699;">UIImage</span> <span style="color:#2e0d6e;">imageNamed</span>: <span style="color:#c41a16;">@"green.png"</span>] ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#5c2699;">CGPoint</span> aPoint ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>// draw the history graph</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">for</span>( i = <span style="color:#1c00cf;">0</span> ; i< [<span style="color:#3f6e74;">dataPoints</span> <span style="color:#2e0d6e;">count</span>] ; i++ )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>x = <span style="color:#643820;">OFFSET_X</span> + i * <span style="color:#3f6e74;">scale_factor_x</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span>old_y = [[</span><span style="color:#3f6e74;">dataPoints</span><span style="color:#000000;"> </span>objectAtIndex<span style="color:#000000;">: i] </span><span style="color:#000000;"> </span>floatValue<span style="color:#000000;">];</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>y = (height -<span style="color:#643820;">OFFSET_Y</span>) - ([[<span style="color:#3f6e74;">dataPoints</span> <span style="color:#2e0d6e;">objectAtIndex</span>: i] <span style="color:#2e0d6e;">floatValue</span>] - <span style="color:#3f6e74;">min_y</span>) * <span style="color:#3f6e74;">scale_factor_y</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">if</span> ( old_x < <span style="color:#1c00cf;">0</span> )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextMoveToPoint</span>( currentContext, x, y );</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>old_x = x ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>else</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>old_x = x ;<span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextAddLineToPoint</span>( currentContext, x, y );</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-style-span" style="color: rgb(170, 13, 145);"> </span></span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>CGContextStrokePath<span style="color:#000000;">(currentContext);</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"> </p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0);"><span class="Apple-style-span" style=" ;font-family:'times new roman';font-size:large;">And now I show you how to add text in the graph (drawing the Y-labels, I will not give the code for the X-labels).</span></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;"><br /></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:'times new roman';font-size:18px;"></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"> </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"> // this is for the font</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextSetRGBStrokeColor</span>(currentContext, <span style="color:#1c00cf;">1</span>, <span style="color:#1c00cf;">1</span>, <span style="color:#1c00cf;">1</span>, <span style="color:#1c00cf;">1</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextSetRGBFillColor</span>(currentContext, <span style="color:#1c00cf;">1.0</span>, <span style="color:#1c00cf;">1.0</span>, <span style="color:#1c00cf;">1.0</span>, <span style="color:#1c00cf;">0.8</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>CGContextSelectFont<span style="color:#000000;">(</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>currentContext,</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>"Helvetica-Bold"<span style="color:#000000;">,</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#643820;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>FONT_SIZE<span style="color:#000000;">,</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>kCGEncodingMacRoman</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>);</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"> // this transformation is to make sure that the text is written in the right direction</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span><span style="color:#5c2699;">CGAffineTransform</span><span style="color:#000000;"> transform = </span>CGAffineTransformMake(<span style="color:#000000;"><span style="color:#1c00cf;">1.0</span>,<span style="color:#1c00cf;">0</span>, <span style="color:#1c00cf;">0.0</span>, -<span style="color:#1c00cf;">1.0</span>, <span style="color:#1c00cf;">0.0</span>, <span style="color:#1c00cf;">0.0<span class="Apple-style-span" style="color: rgb(0, 0, 0); ">);</span></span></span></p><p></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"> <span style="color:#2e0d6e;">CGContextSetTextMatrix</span>(currentContext, transform);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>CGContextSetTextDrawingMode<span style="color:#000000;">(currentContext, </span>kCGTextFill<span style="color:#000000;">);</span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0);"><br /></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"><span class="Apple-style-span" style="color: rgb(0, 0, 0);"></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;">// set Y-labels</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">float</span> j1 = <span style="color:#3f6e74;">min_y</span> ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">float</span> step = (<span style="color:#3f6e74;">max_y</span> - <span style="color:#3f6e74;">min_y</span>)/ <span style="color:#1c00cf;">7.0f</span> ; // 7 labels</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">for</span> ( i = <span style="color:#1c00cf;">0.0f</span> ; i <=height ; i = i + <span class="Apple-style-span" style="color: rgb(28, 0, 207);">OFFSET_X</span> )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span> <span class="Apple-tab-span" style="white-space:pre"> </span>// set the precision of the label</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span> <span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#aa0d91;">if</span> ( j1 > <span style="color:#1c00cf;">999.0f</span> )</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span> s1 = [<span style="color:#5c2699;">NSString</span> <span style="color:#2e0d6e;">stringWithFormat</span>:<span style="color:#c41a16;">@"%4.0f"</span>, j1] ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>else</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>{</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span> s1 = [<span style="color:#5c2699;">NSString</span> <span style="color:#2e0d6e;">stringWithFormat</span>:<span style="color:#c41a16;">@"%4.2f"</span>, j1] ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>j1 += step ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color:#2e0d6e;">CGContextShowTextAtPoint</span>( currentContext,<span style="color:#1c00cf;">0</span> , height - <span style="color:#643820;">OFFSET_Y</span> - i , [s1 <span style="color:#2e0d6e;">UTF8String</span>] , [s1 <span style="color:#2e0d6e;">length</span>] ) ;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre"> </span>}</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p> <p color="#007400" style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; "><span style="color:#000000;"> </span></p> <p color="#2e0d6e" style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; "><span style="color:#000000;"><span class="Apple-tab-span" style="white-space:pre"> </span></span>CGContextStrokePath<span style="color:#000000;">(currentContext);</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"> </p><p></p><p color="#2e0d6e" style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; "><span class="Apple-style-span" style="color: rgb(0, 0, 0);"><br /></span></p><p></p><p></p><div><span class="Apple-style-span" style="font-size:large;">Voila this was it, next time I'll refactor the code and use Paths instead of each time saving and restoring the context</span></div><p></p><p></p><p></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre"> </span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"> </p></div><div style="text-align: left;"><br /></div><div style="text-align: left;"><br /></div>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-53022216327227265122009-12-04T00:09:00.000-08:002009-12-26T06:51:29.668-08:00Its finally thereAfter months of hard work and a long review process by Apple, my first iPhone application is finally accepted on the AppStore.<div><br /></div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica">iSignals, for the active investor. This application integrates with an proprietary investment engine , this investment engine holds a computer-generated portfolio with more than 17000 equities on 28 different stockmarkets and with 9 years of historical data. </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica">On the daily basis the engine generates computer managed portfolios with buy&sells of those equities (portfolio's are organized per market).</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica">The engine is based on a combination of technical analysis models, artificial intelligence (pattern detection) and a neural network.</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica">Via iSignals the user can subscribe to one or more computer managed portfolio's and as such receiving the buy/sells from the engine.</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica">The user can now use those computer generated signals as a guidance in his investment decisions.</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><br /></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica">The advantage of the application is that the user can consult the engine's portfolio's wherever he wants and whenever he wants. The user can also consult quote data for each instrument (data from finance.yahoo.com) on his iPhone/iPod Touch.</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica"><br /></p></div><div>You can find it <a href="http://itunes.apple.com/be/app/isignals/id328171880?mt=8">here</a></div>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-38787598029538789242009-07-31T01:44:00.000-07:002009-07-31T05:52:51.087-07:00iPhone SMS hackI 've downloaded the PDF file that explains in full detail the SMS hack.<div><br /></div><div>You can find it here : <a href="http://www.box.net/shared/bydck05u5n">SMS hack.pdf</a></div><div><br /></div><div>Now 4 caveats :</div><div><br /></div><div>1) They tested it in lab environment, so not by sending real SMS's over a carrier (because that cost money :-) )</div><div><br /></div><div>2) If some hacker really wants to exploit this he will need a lot of phonenumbers (and cash to send the SMS)</div><div><br /></div><div>3) The hacker his identity will be quickly revealed as sending of SMS is not anonymous at all.</div><div><br /></div><div>4) The only thing that the paper described is how to crash an iPhone (and Android GSM) not really taking over the thing. It will be a hard thing to do to really send a program over a carrier via SMS to actually take over an iPhone or an Android GSM </div>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-62067966409725350542009-07-25T06:17:00.000-07:002009-07-25T06:18:26.500-07:00iPhone user experienceFor those developing for the iPhone and struggeling with the UI, I found here a cool article : http://www.smashingmagazine.com/2009/07/21/iphone-apps-design-mistakes-overblown-visuals/MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-60897023129066445692009-07-21T00:34:00.000-07:002009-07-21T00:46:58.320-07:00Multitasking for the iPhone: something simpleWe all known that the iPhone/iPod has a much slower CPU than a 'standard' Mac or PC. So this means that the user experience can be a bit sluggish.<div>So when we have for example a time consuming task it comes in handy to use some multi-tasking capabilities built in , in Cocoa Touch.</div><div><br /></div><div>However , I found out for myself a simpler and less difficult method of giving the user a good experience and still doing a lengthy task.</div><div>Of course this method only applies to tasks which takes 2-4 seconds , for longer tasks you'll need NSThread.</div><div><br /></div><div>The trick I do is that I use an UIActivityIndicatorView somewhere on the screen so when a user 'sees' the screen he in fact see the spinning gear.</div><div>In the mean time the implementation of the time consuming task I do in the <span class="Apple-style-span" style="font-family: 'courier new';">viewDidAppear:</span> method.</div><div><br /></div><div>So what happens is that the user sees a UI with something moving (the gear) so he knows that the application is actually doing something, and if it only takes 2 to 4 seconds he will never get frustrated.</div><div><br /></div><div>I found this much easier than going to the route of NSThread with all the difficulties of locking of shared variables etc.</div><div><br /></div>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-37733468376233919462009-06-13T04:42:00.000-07:002009-06-13T04:50:48.800-07:00IPhone application, iSignals, goes betaOke, it's finally here ! My application goes in beta phase 1.<div>The purpose of the application is to have a portfolio management system with buy and sell signals generated by a backend.</div><div>In the front end you choose the stocks you want to follow and then 3 times a day the backend , a signals engine, will do a technical analysis and send buy/sell signals (if any).</div><div><br /></div><div>For more information please visit the <a href="http://www.isignals.biz/">website</a>.</div><div><br /></div><div>Screenshots :</div><div><br /></div><div><img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhN2RCn7X9Y2bMYofEUnApRsaWOE36JVDzuP1aa7x8FbVDC9RCNbfe5SmpOPglxcy0eb4GPR5AlOjDiom-EX0iDnxuiFzKKZh-f0YHFaAzPK4tPo8BdWAYpau-dLt7G39tkNn2mWwYC-YA/s320/Screenshot+2009.06.13+13.34.54.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5346777426172197890" /><img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfrqe0iTQdyvHjW2WQHAcxlA6N8IyNl_TMC9TfvNF69tUXq_xh6jJu4z1w7l2Q0arZgmA7LjsR07FlYwmr6Vxq6hPAWE5TiHlTDcumdVlDF48hEbiwi210vgz-eZGdnwEm9cq3Do0sS2w/s320/Screenshot+2009.06.13+13.35.03.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5346777671721511090" /><img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEju7a3-aZxjv17qmBk-ZjaZ_LHg0RhmnldZYwjpiUt4h9l9BVeQkVRn0i2zhiRs7eg_3KLvDJRweTlhtLghfltthSO7J0nnQa2Y0tQqiGHYiLHCedxJU9Q0DzodBZxtMSZSvZQ9NjDg21s/s320/Screenshot+2009.06.13+13.35.10.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5346777672834039074" /></div><div><br /></div><div><br /></div><div><img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEideIZQxfOP2WYhvJtZ43ezUtn7unRxMXolI44g5gqP3XsW_QY2QDbo2lAGoDv4bTMRpt2M6lhwh7Nftt97nry0ycGFphWvU_ezGpggE7LLNGKOhDj6H0HEyYZaONu-eYW53sFQKMI970k/s320/Screenshot+2009.06.13+13.35.22.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5346777675791855218" /><img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG8hNcXVH-_NwfOGelZ77Cs2W7ViKgOvYZCJadI5-QVZEAD9O2kbvO4ecCFD1MTVzRKb1Ct4QjPGR8WdaV1-MphlrLKEXCwmJovgwz1-yy57YBHEM84vukPd8Yh2xNdcV4xMXmxYhW3mY/s320/Screenshot+2009.06.13+13.35.39.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5346777680462195474" /><br /></div>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-89785859770162841852009-06-11T14:16:00.000-07:002009-06-13T04:42:30.878-07:00Iphone and memory managementOk, I was busy with some iPhone related developments. Now I realized that the actual memory size of an iPhone is 128 Mb RAM (memory you can use for application, not storage).<div>So this means that your application, usually can't take more than 50 to 60 Mb of RAM.</div><div>For myselfs I've put some guidelines to manage that limitation :</div><div><br /></div><div>1. Never use more memory than needed for the view you are in, so release, release</div><div><br /></div><div>2. Every viewcontroller should be released as soon it's pushed in a navigation controller</div><div><br /></div><div>3. Use proxy's (lazy object creation)</div><div><br /></div><div>4. use SQLite for caching (store your objects in a SQLLite database, this database is not using RAM)</div><div><br /></div><div>5. Prepare your application for the worsed and implement the didRecieveMemoryWarning method</div>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-90908033608758472912009-05-24T00:24:00.000-07:002009-05-26T13:17:31.908-07:00Iphone & Cocoa Touch : the final frontierI'm a bit offline lately because I'm busy with an exciting iPhone app. The goal is to have a business application for the iPhone/iPod which allows the customer to followup a portfolio of stock and getting buy and sell signals.<div>The generation of the signals is based on a very complicated technical analysis engine (it's in use for 7 years now and it has proven its value).</div><div><br /></div><div>Now to get an idea how the application will lookalike I post here some screenshots. </div><div>(ps: the website where you can find some more info is <a href="http://www.isignals.biz/">www.isignals.biz</a> ).</div><div><br /></div><div>The iPhone app will be released in a month or so (maybe after holiday season, so I have sometime to do beta testing).</div><div><br /></div><div><img style="cursor:pointer; cursor:hand;width: 168px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilSI9rNqG65s_YpM2EOcXyA8m2-RGOGB-4jYG6E7JQnEQiAYwpzDuWAHHRPypz4LlUR-jmStC2ike79IPkKSpi_lcHmWQefR7iWlGJzx-0znQGvv19jAY64BC2wd7BWf6o3dwK3bWVQAk/s320/Afbeelding+1.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339289730752849010" /><img style="cursor:pointer; cursor:hand;width: 169px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcSw9NBd14Ua2N_7zeMm3PfwnMEG6NBkPVPil9YIGiM1avhR9qiNq4lqKHRnvF9bC4024QVHAcbp5HAp6HnN9E-EeBr8SP2QZPtJOB9Hy5qWVS-d4xyHnSucPhCz06llGX2K1JCbqB4q4/s320/Afbeelding+4.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339290015441133490" /><img style="cursor:pointer; cursor:hand;width: 170px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIaaW8OTThL5pGp1yiOX0owUk-rJe7Vp_e5ernHw4PP7DoOQy9y-OjjIJz_0MQSQnuspTm-OTIjZR-vrzTKqGJARUplSPMOHpi4XMOlRGWzCFnMo2aCFbNVldRdErNiSO4SdzO78QbapA/s320/Afbeelding+3.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339289933443086018" /><br /></div>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-92203009448059673212009-04-22T13:16:00.000-07:002009-04-22T13:22:07.895-07:00NSDateFormatter in OSX 10.4.11Today I found some strange behaviour in the NSDateFormatter :<br />If I execute the following code :<br /><br /> NSDateFormatter *timeFormatter = [[[NSDateFormatter alloc] init] autorelease];<br /> [timeFormatter setDateStyle:NSDateFormatterNoStyle];<br /> [timeFormatter setTimeStyle:NSDateFormatterMediumStyle];<br /> NSDate *stringTime = [NSDate date];<br /> NSString *formattedDateStringTime = [timeFormatter stringFromDate:stringTime];<br /> [theTime setStringValue: formattedDateStringTime] ;<br /><br />Then , instead of displaying the time, it shows me the date.<br /><br />If I add the following line on top :<br /><br />[NSDateFormatter setDefaultFormatterBehavior: NSDateFormatterBehavior10_4] ;<br /><br />It gives me correctly the time.<br /><br />is this something specific for the 10.4.11 ? Is this behavior also observed in the 10.5.X ?MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-71543439683733791262009-04-18T23:52:00.000-07:002009-04-19T04:19:48.273-07:00Application badge in DockIn Leopard (OSX v10.5 and higher) you have the capability to set an application badge like you can find on iMail for example :<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis09F24yTdzwSF0Eag_5G1hYLVHNCOCtgSp5SrlBoBiaFX6i2OFMOE4VunIVAjPSbb1ZwomYLyc1GBYHLdZ_uFgbreNaqDfx8LlmcdZY4MC0oe5MKRYk2VDnBxDX0OComd7nE_HPTQu84/s1600-h/Afbeelding+1.png"><img style="cursor: pointer; width: 62px; height: 62px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis09F24yTdzwSF0Eag_5G1hYLVHNCOCtgSp5SrlBoBiaFX6i2OFMOE4VunIVAjPSbb1ZwomYLyc1GBYHLdZ_uFgbreNaqDfx8LlmcdZY4MC0oe5MKRYk2VDnBxDX0OComd7nE_HPTQu84/s320/Afbeelding+1.png" alt="" id="BLOGGER_PHOTO_ID_5326292243792574194" border="0" /></a><br /><br />Now for the poor people who still have a pre 10.5 version, or for the people who want more capabilities than what Leopard offers, I wrote an utility class based on the example code found in <a href="http://www.cocoadev.com/index.pl?DockIconCounter">CocoaDev</a>.<br /><br />This utility class does not only gives the capability to draw the badge gives also the possibility to change the position of the badge :<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ-q9gGRrz9834J-Qe3yhSSr-grISBgcQEF5LQkXen_4gREcox4vKUAv2ax4Z_ayYEHAEKG_xSpykrqmLeNAT-A2NhodIUMhkF9e43klfV5g4kcV7YT8FBamoxkW-7DCNi3ILLs7PsO_w/s1600-h/Afbeelding+5.png"><img style="cursor: pointer; width: 81px; height: 66px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ-q9gGRrz9834J-Qe3yhSSr-grISBgcQEF5LQkXen_4gREcox4vKUAv2ax4Z_ayYEHAEKG_xSpykrqmLeNAT-A2NhodIUMhkF9e43klfV5g4kcV7YT8FBamoxkW-7DCNi3ILLs7PsO_w/s320/Afbeelding+5.png" alt="" id="BLOGGER_PHOTO_ID_5326358359253670578" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk94188Uz-25-u2PpvKWv1rqRzBRNO6JxZHS7mDP1QyrOZ-tdJoDiGXPYXAZ5SvDAl47UXxilA0GXTph3J4Ut9gRbq5bk3VSBIXz_abTs1HakB-27651-tneKmrblBZXcuFPGGz5pkpk8/s1600-h/Afbeelding+6.png"><img style="cursor: pointer; width: 76px; height: 67px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk94188Uz-25-u2PpvKWv1rqRzBRNO6JxZHS7mDP1QyrOZ-tdJoDiGXPYXAZ5SvDAl47UXxilA0GXTph3J4Ut9gRbq5bk3VSBIXz_abTs1HakB-27651-tneKmrblBZXcuFPGGz5pkpk8/s320/Afbeelding+6.png" alt="" id="BLOGGER_PHOTO_ID_5326358359655617058" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6XiwIPI9g_1ktKPHYSgBQM75YofcNlI6NOl7kxqLm4mID1-5nmI-CfXLXYBMCZ-QpqYJODbO4B1MfMLNJ9fsLIR9gfa04dhN-NW1al87GJRa-YAhy9ghEqED_WmX-T0tg8Y74DOq8XhI/s1600-h/Afbeelding+4.png"><img style="cursor: pointer; width: 74px; height: 67px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6XiwIPI9g_1ktKPHYSgBQM75YofcNlI6NOl7kxqLm4mID1-5nmI-CfXLXYBMCZ-QpqYJODbO4B1MfMLNJ9fsLIR9gfa04dhN-NW1al87GJRa-YAhy9ghEqED_WmX-T0tg8Y74DOq8XhI/s320/Afbeelding+4.png" alt="" id="BLOGGER_PHOTO_ID_5326358360152897394" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyJwZg41PoOpzB0-XQYPjbsb0LI0asmYt-39jMnAeGPq4R7F4uAsGA6b_tfVxtGi80DPJ-fm4qjc8Uuv9VXBGYX0CfUw7CvNO5xLicPRm2FTGUu4faldurl90g5jDKvuNdGD6zBYplvNI/s1600-h/Afbeelding+3.png"><img style="cursor: pointer; width: 77px; height: 68px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyJwZg41PoOpzB0-XQYPjbsb0LI0asmYt-39jMnAeGPq4R7F4uAsGA6b_tfVxtGi80DPJ-fm4qjc8Uuv9VXBGYX0CfUw7CvNO5xLicPRm2FTGUu4faldurl90g5jDKvuNdGD6zBYplvNI/s320/Afbeelding+3.png" alt="" id="BLOGGER_PHOTO_ID_5326358358006590818" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFJ5-xrz6ibe1OWQj3GaeSWmsUAknLFVbct1vkXzhOWiDlqqZ5JUYP-9Q9t9yH7NLmUolfwAeuB113aMYZULx3T3CmmOXT9lsNDbEtBLQ5doczXaUuks1fHNxJ4SBUey9Xdsk8UzsT11o/s1600-h/Afbeelding+2.png"><img style="cursor: pointer; width: 75px; height: 65px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFJ5-xrz6ibe1OWQj3GaeSWmsUAknLFVbct1vkXzhOWiDlqqZ5JUYP-9Q9t9yH7NLmUolfwAeuB113aMYZULx3T3CmmOXT9lsNDbEtBLQ5doczXaUuks1fHNxJ4SBUey9Xdsk8UzsT11o/s320/Afbeelding+2.png" alt="" id="BLOGGER_PHOTO_ID_5326358356596487490" border="0" /></a><br /><br />Changing the font size of the badge:<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwq5M8dzvnch3oHEzIRPnv9p3Dqi_DbA6Ojs4VVG4h52wsCpayLM6uD1KGz7CVZqeragZJpKwY98LeS1yoJq7LpOTAosAI434BM1xo61_Tqgm3UArrTgXXLNNhGDM4nLnfhEysUu6vB0w/s1600-h/Afbeelding+7.png"><img style="cursor: pointer; width: 77px; height: 71px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwq5M8dzvnch3oHEzIRPnv9p3Dqi_DbA6Ojs4VVG4h52wsCpayLM6uD1KGz7CVZqeragZJpKwY98LeS1yoJq7LpOTAosAI434BM1xo61_Tqgm3UArrTgXXLNNhGDM4nLnfhEysUu6vB0w/s320/Afbeelding+7.png" alt="" id="BLOGGER_PHOTO_ID_5326359435559620338" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIdXiY0cRyCDZ-5p9kTRwKB46fIKFNEQyFzl73vUxv5wqx410nnY1jA9runTj1q3JIweNDYmyQrcTy2OXwtK-tE6OQX31fgAq7fPdVurYd_YxY8zisNQDZSwVODSqZ7PgSnKnIdW2A7uc/s1600-h/Afbeelding+8.png"><img style="cursor: pointer; width: 77px; height: 70px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIdXiY0cRyCDZ-5p9kTRwKB46fIKFNEQyFzl73vUxv5wqx410nnY1jA9runTj1q3JIweNDYmyQrcTy2OXwtK-tE6OQX31fgAq7fPdVurYd_YxY8zisNQDZSwVODSqZ7PgSnKnIdW2A7uc/s320/Afbeelding+8.png" alt="" id="BLOGGER_PHOTO_ID_5326359439430885330" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWfZb54UchL6fGlYEz9kqb3gvQIiITLjr9xVD084ZRpb-B4CruY_28qNDP1Ba_U1aE_PC-rtyPXglRqKjKldWqxrye2JZVtS3HeH46g1SovBIgwjG102P3hf3LI4k_qCD7H64fQDLUe0g/s1600-h/Afbeelding+9.png"><img style="cursor: pointer; width: 78px; height: 70px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWfZb54UchL6fGlYEz9kqb3gvQIiITLjr9xVD084ZRpb-B4CruY_28qNDP1Ba_U1aE_PC-rtyPXglRqKjKldWqxrye2JZVtS3HeH46g1SovBIgwjG102P3hf3LI4k_qCD7H64fQDLUe0g/s320/Afbeelding+9.png" alt="" id="BLOGGER_PHOTO_ID_5326359440807623426" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcFys3ClNj91to9FOVjgpb6qJYLo8sLRXAIZmuRDzeZSJD1x_5fSxmZ5S9XHp-KCbsWfU0ZJyOvYAxqBKc1ECmpS0OoLTDiIUuNHCKTrduXYAJH7hc1VhxpZInWNdODu_fHe6MtKUzSAw/s1600-h/Afbeelding+10.png"><img style="cursor: pointer; width: 76px; height: 70px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcFys3ClNj91to9FOVjgpb6qJYLo8sLRXAIZmuRDzeZSJD1x_5fSxmZ5S9XHp-KCbsWfU0ZJyOvYAxqBKc1ECmpS0OoLTDiIUuNHCKTrduXYAJH7hc1VhxpZInWNdODu_fHe6MtKUzSAw/s320/Afbeelding+10.png" alt="" id="BLOGGER_PHOTO_ID_5326359443010504594" border="0" /></a><br /><br />Changing the color of the badge:<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqkxfODE6pF1cD80fcpAlQupbDWaalhkU4euOKDfMBmutnqQxW39sFjTQD1zZx-jrd4D6Z-3kiUU04RdfqGknwQI39X9CTK_AxPS8JQZp4HhJeu0NsYtLw1nInEjSKuXad9l3EGokAmdQ/s1600-h/Afbeelding+13.png"><img style="cursor: pointer; width: 75px; height: 69px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqkxfODE6pF1cD80fcpAlQupbDWaalhkU4euOKDfMBmutnqQxW39sFjTQD1zZx-jrd4D6Z-3kiUU04RdfqGknwQI39X9CTK_AxPS8JQZp4HhJeu0NsYtLw1nInEjSKuXad9l3EGokAmdQ/s320/Afbeelding+13.png" alt="" id="BLOGGER_PHOTO_ID_5326360158357819202" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPZvcZKBxfyMNP9_p7VI8H56wnkuRtWIbT6eoE4Qr4UPQ-U_lycSEVOlt-6mtIBcK4EFA0hPNJM5xOgVJzMbKGrBpoXRlehjPvkodTxrnKMfRZdE7qJnpv2cbv0CY_B6Z40d6lW8v3AF0/s1600-h/Afbeelding+12.png"><img style="cursor: pointer; width: 77px; height: 73px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPZvcZKBxfyMNP9_p7VI8H56wnkuRtWIbT6eoE4Qr4UPQ-U_lycSEVOlt-6mtIBcK4EFA0hPNJM5xOgVJzMbKGrBpoXRlehjPvkodTxrnKMfRZdE7qJnpv2cbv0CY_B6Z40d6lW8v3AF0/s320/Afbeelding+12.png" alt="" id="BLOGGER_PHOTO_ID_5326360158409647346" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3tBNsCJFSrtCkckDZDYjkZUyN8atgJwH_NuOUFEw49ZIundU7Jm_NBGJvgXPtrPo7PX3oyObGpjPm4YRdWIK1KLYDcjGuaWGJLDubHfEDDvALmBJyEWLuExycgXyYG4ENEMyLD3DBXDc/s1600-h/Afbeelding+11.png"><img style="cursor: pointer; width: 78px; height: 72px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3tBNsCJFSrtCkckDZDYjkZUyN8atgJwH_NuOUFEw49ZIundU7Jm_NBGJvgXPtrPo7PX3oyObGpjPm4YRdWIK1KLYDcjGuaWGJLDubHfEDDvALmBJyEWLuExycgXyYG4ENEMyLD3DBXDc/s320/Afbeelding+11.png" alt="" id="BLOGGER_PHOTO_ID_5326360154238642738" border="0" /></a><br /><br />The code can be downloaded <a href="http://www.box.net/shared/gzc2hde0lq">here</a>.MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-384303309302613952009-04-16T23:43:00.000-07:002009-04-16T23:46:39.822-07:00NSNumberformatter: some examplesI was looking for some examples on the usage of the NSNumberformatter class. During this search I stumbled on the <a href="http://samuellam.wordpress.com/">weblog of Sam Lam</a> which provides some good examples.<br /><br />I copy them here , as I use my own blog as a sort of FAQ or HOW-TO for myself.<br /><br /><span style="font-size:85%;"><span style="font-family: courier new;">-(NSString*) formatCurrencyValue:(double)value</span><br /><span style="font-family: courier new;">{</span><br /><span style="font-family: courier new;"> NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];</span><br /><span style="font-family: courier new;"> [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];</span><br /><span style="font-family: courier new;"> [numberFormatter setCurrencySymbol:@"$"];</span><br /><span style="font-family: courier new;"> [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];</span><br /><span style="font-family: courier new;"> NSNumber *c = [NSNumber numberWithFloat:value];</span><br /><span style="font-family: courier new;"> return [numberFormatter stringFromNumber:c];</span><br /><span style="font-family: courier new;">}</span><br /><br /><span style="font-family: courier new;">-(NSString*) formatPercentValue:(double)value</span><br /><span style="font-family: courier new;">{</span><br /><span style="font-family: courier new;"> NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];</span><br /><span style="font-family: courier new;"> [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];</span><br /><span style="font-family: courier new;"> [numberFormatter setPercentSymbol:@"%"];</span><br /><span style="font-family: courier new;"> [numberFormatter setNumberStyle: NSNumberFormatterPercentStyle];</span><br /><span style="font-family: courier new;"> [numberFormatter setDecimalSeparator:@"."];</span><br /><span style="font-family: courier new;"> [numberFormatter setGeneratesDecimalNumbers:TRUE];</span><br /><span style="font-family: courier new;"> [numberFormatter setMinimumFractionDigits:2];</span><br /><span style="font-family: courier new;"> [numberFormatter setRoundingMode: NSNumberFormatterRoundUp];</span><br /><span style="font-family: courier new;"> [numberFormatter setRoundingIncrement:[[NSNumber alloc]initWithDouble:0.05]];</span><br /><span style="font-family: courier new;"> NSNumber *c = [NSNumber numberWithFloat:value];</span><br /><span style="font-family: courier new;"> return [numberFormatter stringFromNumber:c];</span><br /><span style="font-family: courier new;">}</span><br /><br /><span style="font-family: courier new;">-(double) formatDoubleFromCurrency:(NSString*)value</span><br /><span style="font-family: courier new;">{</span><br /><span style="font-family: courier new;"> double ret ;</span><br /><span style="font-family: courier new;"> if(value)</span><br /><span style="font-family: courier new;"> {</span><br /><span style="font-family: courier new;"> ret = [value doubleValue];</span><br /><span style="font-family: courier new;"> if (ret == 0)</span><br /><span style="font-family: courier new;"> {</span><br /><span style="font-family: courier new;"> NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];</span><br /><span style="font-family: courier new;"> [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];</span><br /><span style="font-family: courier new;"> [numberFormatter setCurrencySymbol:@"$"];</span><br /><span style="font-family: courier new;"> [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];</span><br /><span style="font-family: courier new;"> NSNumber *c = [numberFormatter numberFromString:value];</span><br /><span style="font-family: courier new;"> ret = [c doubleValue];</span><br /><span style="font-family: courier new;"> }</span><br /><span style="font-family: courier new;"> return ret;</span><br /><span style="font-family: courier new;"> }</span><br /><span style="font-family: courier new;"> else</span><br /><span style="font-family: courier new;"> return 0.0;</span><br /><span style="font-family: courier new;">}</span></span>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-59979665426235998092009-04-16T12:55:00.000-07:002009-04-16T12:59:13.956-07:00NSButton: setting an image in a buttonI always have trouble to know how to set an image in a button. The following code snippet does the job:<br /><br /> NSString* im1 = [[NSBundle mainBundle] pathForResource:@"arrow right" ofType:@"png"];<br /> NSURL* url2 = [NSURL fileURLWithPath:im1];<br /> NSImage *image = [[NSImage alloc] initWithContentsOfURL: url2];<br /> <br /> <br /> [toggleButton setImage: image] ;<br /> <br /> NSString *im2 = [[NSBundle mainBundle] pathForResource:@"arrow left" ofType:@"png"];<br /> url2 = [NSURL fileURLWithPath:im2];<br /> image = [[NSImage alloc] initWithContentsOfURL: url2];<br /> [toggleButton setAlternateImage: image] ;<br /><br />The code above set's 2 images in a toggle button .<br /><br />Note that if you want transparant images , you need .png files and not jpeg's (GIF also works)MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-2052665276622716412009-04-16T06:23:00.000-07:002011-01-19T09:35:52.617-08:00For telenet users: a telemeter application<div><span class="Apple-style-span" style="color:#CC0000;"><br /></span></div><div><span class="Apple-style-span" style="color:#CC0000;"><br /></span></div><div><span class="Apple-style-span" style="color:#CC0000;">Note: the application is updated ! It's now compatible with the new Telemeter service of Telenet (new version since July 2010)</span></div><div><span class="Apple-style-span" style="color:#CC0000;"><br /></span></div><div><span class="Apple-style-span" style="color:#CC0000;">Also available for the iPhone see following <a href="http://mac-objective-c.blogspot.com/2010/08/telenet-telemeter-for-iphoneipod.html">blog message</a> .</span></div><div><span class="Apple-style-span" style="color:#CC0000;"><br /></span></div>This little <a href="http://www.box.net/shared/2ksfgds4r6">application</a> shows how much data you've downloaded/uploaded from your Telenet account.<div>(for the impatients : you can find the dmg <a href="http://www.box.net/shared/2ksfgds4r6">here</a> ) .<br /><br /><img style="cursor:pointer; cursor:hand;width: 320px; height: 254px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxrJQ3CR62vtOI01etCg4C58aTk15ONtYS3Uct8OGr7cKAEP4m-NUR2nLLELkXc9V7Y2PUCx8WvdrrK7491q1zsSYE9Jgofqx0Rwcy2UNjZXLiPhn5FOvGKoC2DAI4gNHF5sqCjVJSEI0/s320/Schermafbeelding+2010-07-22+om+13.29.28.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5496692830242338706" /></div><div><br /></div><div>For those with an unlimited download (turbonet, fibernet) the screen will look like follows :</div><div><br /></div><div><img style="cursor:pointer; cursor:hand;width: 320px; height: 256px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZpFuZ5SkbMoz_9UMPU2MtD5GoxMOxUcLlnlHrue6d2Fz2UgYXY9wCfwCRrR4usV-jVy2WEMFUUcgdbYb4u860EkwNnZ-IXVL2kaAvqoonxcz5wlmtGXgawauvcLXEGpOFqtDoYhO1KIs/s320/Schermafbeelding+2010-07-31+om+11.39.49.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5500005432041495330" /><br /><br />Installation is very easy :<br /><br />1. Open the dmg file (<a href="http://www.box.net/shared/2ksfgds4r6">download here</a>) ;<br />2. drag and drop the folder 'Telemeter' wherever you want ;<br />3. Start the Telemeter v2 application.<br /><br />The very first thing when you start the application a popup will come up to warn you that you need to set your telenet username/password . This can be done clicking the green user icon (on the first line on the right). And if all is oke you should see your usage.<br /><br />In the screen you see also a button with an arrow (>) , if you click that you'll get the daily usage details.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX8SXJRcaQ2CZmWHZc9Uy5eWdeIzf1q3wf8t_u2jFc3m82YImKxodDRJDFT76cWdwsbx-Rf4KbCne0nKA5GbAXg2THyQCuK-6Et-Z9lz_oxM62SmZRqEFSvYi-4nRapMuNeXN91VHJ9Ew/s1600-h/Afbeelding+2.png"><img style="cursor: pointer; width: 320px; height: 145px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX8SXJRcaQ2CZmWHZc9Uy5eWdeIzf1q3wf8t_u2jFc3m82YImKxodDRJDFT76cWdwsbx-Rf4KbCne0nKA5GbAXg2THyQCuK-6Et-Z9lz_oxM62SmZRqEFSvYi-4nRapMuNeXN91VHJ9Ew/s320/Afbeelding+2.png" alt="" id="BLOGGER_PHOTO_ID_5328631410821351570" border="0" /></a><br /><br />The application will update the data from Telenet every 30 minutes.<br /><br /><enter><br /></enter><br /><enter>Next enhancements :<br /></enter><br /><enter>1. Make a dashboard widget of it<br />2. Change the icon colour depending on the used bandwidth<br /><br /><br />Note: this is a first version , so please report any bugs to me (via blog or email). Comments are also welcome of course.<br /></enter><br /><enter><span style="font-size:130%;"><span style="font-weight: bold;">UPDATE</span></span> :<br /></enter><br /><enter>I made the following enhancements :<br /><br />1. you see in the tray bar (system menu bar) the percentage used :<br /><br /></enter><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifO_0drPtMtvMwS-VaCSt7rz8kGahv0u0E2s7LlTp6q0AqU6t4t_MHlviHV-9CG3OAfuZD8u7lxo6Fxkg57JUUPjypcc2QmM_B9O-_M3v4pFnz8EkGg_1VlRDFhF3crdriMWmCzY5ScdY/s1600-h/Afbeelding+2.png"><img style="cursor: pointer; width: 320px; height: 18px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifO_0drPtMtvMwS-VaCSt7rz8kGahv0u0E2s7LlTp6q0AqU6t4t_MHlviHV-9CG3OAfuZD8u7lxo6Fxkg57JUUPjypcc2QmM_B9O-_M3v4pFnz8EkGg_1VlRDFhF3crdriMWmCzY5ScdY/s320/Afbeelding+2.png" alt="" id="BLOGGER_PHOTO_ID_5325690707548174850" border="0" /></a><br /><br />2. In the dock , the icon will also show the percentage used<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4WC_qsSkw_oZ3d5AhLQM1tYShtn3AflC3F87R1ICep9qQ-piINP1rUWlZqp7v02Jlq9pEX8ot-W-N1XUp-DGQU9CsOM3nJ-MVA8CdbHFVGDme2Q0PDKAcGl10OcHSh7twyW1RtUk4g0A/s1600-h/Afbeelding+1.png"><img style="cursor: pointer; width: 320px; height: 49px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4WC_qsSkw_oZ3d5AhLQM1tYShtn3AflC3F87R1ICep9qQ-piINP1rUWlZqp7v02Jlq9pEX8ot-W-N1XUp-DGQU9CsOM3nJ-MVA8CdbHFVGDme2Q0PDKAcGl10OcHSh7twyW1RtUk4g0A/s320/Afbeelding+1.png" alt="" id="BLOGGER_PHOTO_ID_5325691054197717810" border="0" /></a><br /><br />3. several small bugfixes</div><div><br /></div><div><span class="Apple-style-span" style="font-weight: bold;">UPDATE</span> <span class="Apple-style-span" style="font-weight: bold;">2</span>: just found out that I have some memory leaks, will solve them ASAP.</div><div><br /></div><div><span class="Apple-style-span" style="font-weight: bold;">UPDATE</span> <span class="Apple-style-span" style="font-weight: bold;">3</span> : memory leaks solved + some minor improvements<br /><br /><span style="font-weight: bold;">UPDATE</span> <span class="Apple-style-span" style="font-weight: bold;">4</span> : major enhancements<br /></div><div><br /></div><div><span class="Apple-style-span" style="font-weight: bold;">UPDATE 5</span> : Currently (5 May) telemeter service is down</div><div><br /></div><div><span class="Apple-style-span" style="font-weight: bold;">UPDATE 6</span>: We are 7th of May and the telemeter service is still down. And this in Internet age....</div><div><br /></div><div><span class="Apple-style-span" style="font-weight: bold;">UPDATE 7</span>: And now they've changed the protocol.... pff they really annoy me. I changed the XML processing , so it works again</div><div><br /></div><div><b>UPDATE 8</b>: Application rewritten because Telenet has changed completely the webservice</div>MacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com10tag:blogger.com,1999:blog-1101980925257123316.post-61191872721549490452009-04-14T00:40:00.000-07:002009-04-14T01:01:32.111-07:00Drawing pie chartsRecently I was looking for a way to draw pie charts (you know, the one with an 'exploded' slice) on my Macbook.<br />Unfortunealy I didn't find much on the Internet, so I've started to experiment a bit myselfs.<br />The following code draws a pie chart with one slice exploded from the other :<br /><br />The trick is that you draw an imaginary circle around the center, on this circle is the center of the 'exploded' slice.<br /><br /><span style="font-size:85%;"><span style="font-family:courier new;">#define PI 3.14159265358979323846</span></span><br /><br /><span style="font-size:85%;"><span style="font-family:courier new;"> NSBezierPath *greenPath = [NSBezierPath bezierPath] ;<br /></span><br />// set some line width<br /><br /> <span style="font-family:courier new;">[greenPath setLineWidth: 2 ] ;<br /></span><span style="font-family:courier new;"><br />// move to the center so that we have a closed slice<br /> // size_x and size_y are the height and width of the view<br /><br />[greenPath moveToPoint: NSMakePoint( size_x/2, size_y/2 ) ] ;<br /></span><br />// draw an arc (perc is a certain percentage ; something between 0 and 1<br /> <span style="font-family:courier new;">[greenPath appendBezierPathWithArcWithCenter:NSMakePoint( size_x/2, size_y/2) radius:50 startAngle:0 endAngle: 360 * perc ] ;</span><br /><br />// close the slice , by drawing a line to the center<br /><span style="font-family:courier new;">[greenPath lineToPoint: NSMakePoint(size_x/2, size_y/2) ] ;</span><br /><span style="font-family:courier new;"> [greenPath stroke] ;<br /></span><br /><span style="font-family:courier new;"> [[NSColor greenColor] set] ;<br /></span>// and fill it<br /> <span style="font-family:courier new;">[greenPath fill] ;</span> <span style="font-family:courier new;"> </span> <span style="font-family:courier new;"> <br /><br />greenPath = [NSBezierPath bezierPath] ;</span><br /><span style="font-family:courier new;"> [[NSColor blackColor] set] ;</span><br /> <span style="font-family:courier new;">[greenPath setLineWidth: 2 ] ;<br /><br />// draw the second slice, now exploded from the original center<br /><br />// so to get it exploded I move (10,7) points from the original center<br />// but on the imaginary circle (thats why the cos and the sin)<br />// note mide_angle is the angle halve way from the arc, you can experiment with multiple<br />// angles, note also that the angle is in degrees<br /></span> <span style="font-family:courier new;">[greenPath moveToPoint: NSMakePoint(size_x/2 - 10 * cos ( PI * mid_angle / </span></span><span style="font-size:85%;"><span style="font-family:courier new;">180 ) , size_y/2 - 7 * sin ( PI * mid_angle / 180 )) ] ;<br /><br />// and now draw the other slice<br /></span> <span style="font-family:courier new;">[greenPath appendBezierPathWithArcWithCenter:NSMakePoint( size_x/2 - 10 * cos ( PI * mid_angle / 180 ) , size_y/2 - 7 * sin ( PI * mid_angle / 180 )) radius:50 startAngle:360 * perc endAngle:360 ] ;<br /><br />// close the slice<br /></span> <span style="font-family:courier new;">[greenPath lineToPoint: NSMakePoint( size_x/2 - 10 * cos ( PI * mid_angle / 180 ) , size_y/2 - 7 * sin ( PI * mid_angle / 180 ) ) ] ;</span><br /><span style="font-family:courier new;"> [greenPath stroke] ;<br /></span> <span style="font-family:courier new;">[[NSColor blueColor] set] ;<br /><br /></span> <span style="font-family:courier new;">[greenPath fill] ;</span></span><br /><br />The result of above code is here :<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgahT31ErFSeC9LzL3O7CU3k3c4zDMPnLCJ3CVF90bkTcGNwEHJ00fm9YcMYpj2eFGcNGqB8lAnhPV9jm6Ki-orlHUfSM-AMIkUqvRlR7cPwo21vLDIf4fOSouXwsoUg1f1Te25OH8VRJY/s1600-h/Afbeelding+1.png"><img style="cursor: pointer; width: 122px; height: 118px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgahT31ErFSeC9LzL3O7CU3k3c4zDMPnLCJ3CVF90bkTcGNwEHJ00fm9YcMYpj2eFGcNGqB8lAnhPV9jm6Ki-orlHUfSM-AMIkUqvRlR7cPwo21vLDIf4fOSouXwsoUg1f1Te25OH8VRJY/s320/Afbeelding+1.png" alt="" id="BLOGGER_PHOTO_ID_5324451830683000930" border="0" /></a><br /><br />Next time I'll add some code to add text to the slicesMacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0tag:blogger.com,1999:blog-1101980925257123316.post-81022388959633695162009-04-07T23:26:00.000-07:002009-04-08T00:06:40.740-07:00SOAP: webservices in Objective-C/CocoaLately I was experimenting a bit with webservices, and this for a good reason : my ISP was trying to bill me extra gigabytes while I was sure I didn't used my full quota.<br />My ISP (telenet in Belgium) is using a nice web page where you can check your quota but they also offer a webservice which gives full statistics on the bandwidth usage.<br /><br />So I decided to build a Dashboard widget (in Objective-C, not in Javascript) to see the statistics from my desktop.<br /><br />Now I didn't do any SOAP/Webservices since a long time , and I never did in Objective-C (my experience goes back to VisualWave, Smalltalk and Java).<br />So I did some experimentation with the samples from Apple itself :<br /><br /><span style="font-size:85%;"><br /><span style="font-family: courier new;"> <span style="font-size:78%;"> // SOAP request settings<br /><br /> NSURL *url = [NSURL URLWithString:@"https://telemeter4tools.services.telenet.be/TelemeterService"];<br /><br /> // the name of the webservice<br /> NSString *method = @"getUsage";<br /><br /> // the namespace<br /> NSString *namespace = @"https://telemeter4tools.services.telenet.be/";<br /><br /> </span></span><span style="font-size:78%;"><br /><span style="font-family: courier new;"> // SOAP request params</span><br /><span style="font-family: courier new;"><br /> NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"**username**",</span><br /><span style="font-family: courier new;"> @"string",</span><br /><span style="font-family: courier new;"> @"**password**",</span><br /><span style="font-family: courier new;"> @"string0",</span><br /><span style="font-family: courier new;"> nil];<br /><br /> // the parameters itself are in a dictionary, a dictionary is an unordered collection<br /> // so to define the order in which the parameters must be sent<br /> // you need to fill an array with the NAMES of the parameters<br /><br /> NSArray *paramOrder = [NSArray arrayWithObjects:@"string", @"string0"];</span><br /><span style="font-family: courier new;"> </span><br /><span style="font-family: courier new;"><br /> // set SOAP request http headers -- some SOAP server impls require even empty SOAPAction headers</span><br /><span style="font-family: courier new;"><br /><br /> NSDictionary *reqHeaders = [NSDictionary dictionaryWithObject:@"" forKey:@"SOAPAction"];</span><br /><span style="font-family: courier new;"> </span><br /><span style="font-family: courier new;"><br /> // create SOAP request</span><br /><span style="font-family: courier new;"><br /> WSMethodInvocationRef soapReq = createsoapReq(url, method, namespace, params, paramOrder, reqHeaders);</span><br /><span style="font-family: courier new;"> </span><br /><span style="font-family: courier new;"><br /> // invoke SOAP request</span><br /><span style="font-family: courier new;"><br /> NSDictionary *result = (NSDictionary *)WSMethodInvocationInvoke(soapReq);</span><br /><br /><span style="font-family: courier new;"><br /> // get HTTP response from SOAP request so we can see response HTTP status code</span><br /><span style="font-family: courier new;"><br /> CFHTTPMessageRef res = (CFHTTPMessageRef)[result objectForKey:(id)kWSHTTPResponseMessage];</span></span></span><br /> <br /> The response of a SOAP requests is a dictionary, and it looks like this :<br /><br />result: {<br /> "/Result" = { ... <<>> };<br /><br /> "/WSDebugInBody" = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><env:envelope env="\" xsi="\" soapenc="\" xsd="\"><env:body encodingstyle="\"><m:getusageresponse m="\">...etc;<br /><br /> "/WSDebugInHeaders" = {<br /> "Accept-Ranges" = none;<br /> Connection = close;<br /> "Content-Length" = 4840;<br /> "Content-Type" = "text/xml; charset=utf-8";<br /> Date = "Wed, 08 Apr 2009 06:44:46 GMT";<br /> "Set-Cookie" = "JSESSIONID=JcHpkYZkhhn2pzp1LY7fvGQ1WXkb24WKDY2LBnf0JpLYyhsk23Q1!-344393110; path=/, st8id=c42908deb564326d86d900fd90459934.01.af0318b08a904d84c5824b76a132ab93; domain=.services.telenet.be; path=/, st8id_wat_%2Eservices%2Etelenet%2Ebe_%2F=SlNFU1NJT05JRA__?1607678332ef30e3c1b9fc43cda54cb6; domain=.services.telenet.be; path=/";<br /> };<br /> "/WSDebugOutBody" = <<>>";<br /> "/WSDebugOutHeaders" = {<br /> "Content-Type" = "text/xml";<br /> Host = "telemeter4tools.services.telenet.be";<br /> Soapaction = "";<br /> "User-Agent" = "Mac OS X; WebServicesCore.framework (1.1.0)";<br /> };<br /> "/kWSHTTPResponseMessage" = <<>><br />}<br /><br />Note that I stripped a bit the contents of the dictionary.<br /><br />Now to get the result of the webservice you must get the proper data from the dictionary (in this case this is <span style="font-family: courier new;">data = [result objectForKey: @"result"]</span>.<br /><br />This will return a string value, so a next step is to create an XMLDocument of it :<br /><br /> <span style="font-family: courier new;">NSXMLDocument *document ;</span><br /><span style="font-family: courier new;"> NSError *error ;</span><br /><span style="font-family: courier new;"> NSXMLNode *node ;</span><br /><span style="font-family: courier new;"> document = (NSXMLDocument *) [NSXMLDocument document] ;</span><br /><span style="font-family: courier new;"> [document initWithXMLString: data options: NSXMLDocumentTidyXML error: &error ] </span>;<br /><br />And once it is in a XMLDocument , you can use XPath expressions to query the document :<br /><br /><span style="font-family: courier new;">myArray = [document objectsForXQuery: @"/ns1:telemeter[1]/ns1:usage-info[1]/ns1:data[1]/@timestamp" error: &error ] ;</span><br /><br />Now this looks to me a very complex process to get something from a webservice.<br />I'm now looking at WSDL and the utility WSMakeStubs to see if I can simplify this.<br />The nicest thing would be that we have something like JAXB to 'objectify' webservice responsesMacAddicthttp://www.blogger.com/profile/09241791588496167155noreply@blogger.com0