<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CkUAQnc5eyp7ImA9WhRRFkQ.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316</id><updated>2011-11-30T13:57:23.923-08:00</updated><category term="OO concepts" /><category term="core data" /><category term="path" /><category term="finance" /><category term="special number format" /><category term="trading" /><category term="sell" /><category term="buy" /><category term="custom view" /><category term="telenet" /><category term="sms hack" /><category term="awakeFromNib" /><category term="MiniVMac" /><category term="application badge" /><category term="stock market" /><category term="telemeter" /><category term="IPhone" /><category term="IBAction" /><category term="mac osx" /><category term="depth first search" /><category term="timer" /><category term="Smalltalk" /><category term="Cocoa Touch" /><category term="sales" /><category term="apps" /><category term="radiobutton" /><category term="HelloWorld" /><category term="Graphics context" /><category term="Cloud computing" /><category term="SMS" /><category term="checkbox" /><category term="portfolio management systems" /><category term="producer" /><category term="exploded arc" /><category term="IBOutlet" /><category term="graphics" /><category term="CGPath" /><category term="XML" /><category term="financial application" /><category term="memory" /><category term="integrating with helpviewer" /><category term="NSBezierPath" /><category term="Citrix" /><category term="UISegmentedControl" /><category term="drawrect" /><category term="beta" /><category term="observer" /><category term="emulation" /><category term="matrix enumerator" /><category term="Webservices" /><category term="nsanimation" /><category term="text" /><category term="pimm" /><category term="NSNumberFormatter" /><category term="messages" /><category term="UiSegment" /><category term="dock icon" /><category term="itunes" /><category term="examples" /><category term="technical analysis" /><category term="Outlet" /><category term="blocks" /><category term="slice" /><category term="isignals" /><category term="consumer" /><category term="NSThread" /><category term="MVC" /><category term="apple" /><category term="2-dimensional data structure" /><category term="date formatter" /><category term="Sophis" /><category term="currency" /><category term="delegation" /><category term="help" /><category term="grid" /><category term="nsnotification" /><category term="design pattern" /><category term="WSDL" /><category term="Tetris" /><category term="pie chart" /><category term="frameworks" /><category term="ios" /><category term="Objective-C" /><category term="object initialization" /><category term="background" /><category term="UIView" /><category term="NSDateFormatter" /><category term="saving data" /><category term="game of life" /><category term="database" /><category term="self = [super init]" /><category term="NSImage" /><category term="user experience" /><category term="appstore" /><category term="init" /><category term="drawing" /><category term="showHelp" /><category term="Maze" /><category term="Informatica" /><category term="views" /><category term="tutorial" /><category term="objects" /><category term="iPhone OS" /><category term="OO" /><category term="font" /><category term="signals" /><category term="SOAP" /><category term="board games" /><category term="OS9" /><category term="HelpViewer" /><category term="nstimer" /><category term="matrix" /><category term="texture" /><category term="trading room" /><category term="Cocoa" /><category term="maze generation" /><category term="drawing in views" /><category term="quotes" /><category term="rectangles" /><title>Cocoa Tidbits</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>55</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/Objective-c" /><feedburner:info uri="objective-c" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><entry gd:etag="W/&quot;AkMDQ3c_eCp7ImA9Wx5SEE8.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-2926166611705296303</id><published>2010-08-05T10:03:00.000-07:00</published><updated>2010-08-05T10:14:32.940-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-08-05T10:14:32.940-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="special number format" /><category scheme="http://www.blogger.com/atom/ns#" term="currency" /><category scheme="http://www.blogger.com/atom/ns#" term="NSNumberFormatter" /><title>NSNumberformatter for special currency formats</title><content type="html">Another day somebody asked me if it was possible with an NSNumberFormatter to format currency values like $1k , $1,02m etc.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So instead of displaying a value like $1,020,000 to display it as $1,02m&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now with a standard NSNumberFormatter its not possible, so you could create a custom formatter for that.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The following code snippet will do the job&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;- (&lt;span style="color: #7e1ead"&gt;NSString&lt;/span&gt; *) formatCurrencyValue: (&lt;span style="color: #d200a5"&gt;double&lt;/span&gt; )doubleValue &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7e1ead"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;NSNumberFormatter&lt;span style="color: #000000"&gt; *nformat = [[&lt;/span&gt;NSNumberFormatter&lt;span style="color: #000000"&gt; &lt;/span&gt;&lt;span style="color: #470085"&gt;alloc&lt;/span&gt;&lt;span style="color: #000000"&gt;] &lt;/span&gt;&lt;span style="color: #470085"&gt;init&lt;/span&gt;&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #470085"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[nformat &lt;/span&gt;setFormatterBehavior&lt;span style="color: #000000"&gt;:&lt;/span&gt;NSNumberFormatterBehavior10_4&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #470085"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[nformat &lt;/span&gt;setCurrencySymbol&lt;span style="color: #000000"&gt;:[[&lt;/span&gt;&lt;span style="color: #7e1ead"&gt;NSLocale&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;currentLocale&lt;span style="color: #000000"&gt;] &lt;/span&gt;objectForKey&lt;span style="color: #000000"&gt;: &lt;/span&gt;&lt;span style="color: #7e1ead"&gt;NSLocaleCurrencySymbol&lt;/span&gt;&lt;span style="color: #000000"&gt;]];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #470085"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[nformat &lt;/span&gt;setNumberStyle&lt;span style="color: #000000"&gt;:&lt;/span&gt;NSNumberFormatterCurrencyStyle&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #7e1ead"&gt;NSString&lt;/span&gt; *stringValue = &lt;span style="color: #d200a5"&gt;nil&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #7e1ead"&gt;NSArray&lt;/span&gt; *abbrevations = [&lt;span style="color: #7e1ead"&gt;NSArray&lt;/span&gt; &lt;span style="color: #470085"&gt;arrayWithObjects&lt;/span&gt;:&lt;span style="color: #ea0008"&gt;@"k"&lt;/span&gt;, &lt;span style="color: #ea0008"&gt;@"m"&lt;/span&gt;, &lt;span style="color: #ea0008"&gt;@"b"&lt;/span&gt;, &lt;span style="color: #ea0008"&gt;@"t"&lt;/span&gt;, &lt;span style="color: #d200a5"&gt;nil&lt;/span&gt;] ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #d200a5"&gt;for&lt;/span&gt; (&lt;span style="color: #7e1ead"&gt;NSString&lt;/span&gt; *s &lt;span style="color: #d200a5"&gt;in&lt;/span&gt; abbrevations)&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;doubleValue /= &lt;span style="color: #3700de"&gt;1000.0&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color: #d200a5"&gt;if&lt;/span&gt; ( doubleValue &lt; &lt;span style="color: #3700de"&gt;1000.0&lt;/span&gt; )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;span style="color: #d200a5"&gt;if&lt;/span&gt; ( (&lt;span style="color: #d200a5"&gt;long&lt;/span&gt; &lt;span style="color: #d200a5"&gt;long&lt;/span&gt;)doubleValue % (&lt;span style="color: #d200a5"&gt;long&lt;/span&gt; &lt;span style="color: #d200a5"&gt;long&lt;/span&gt;) &lt;span style="color: #3700de"&gt;100&lt;/span&gt;   == &lt;span style="color: #3700de"&gt;0&lt;/span&gt; )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #470085"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;[nformat &lt;/span&gt;setMaximumFractionDigits&lt;span style="color: #000000"&gt;:&lt;/span&gt;&lt;span style="color: #3700de"&gt;0&lt;/span&gt;&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;            &lt;span style="color: #d200a5"&gt;else&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #470085"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;[nformat &lt;/span&gt;setMaximumFractionDigits&lt;span style="color: #000000"&gt;:&lt;/span&gt;&lt;span style="color: #3700de"&gt;2&lt;/span&gt;&lt;span style="color: #000000"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;stringValue = [&lt;span style="color: #7e1ead"&gt;NSString&lt;/span&gt; &lt;span style="color: #470085"&gt;stringWithFormat&lt;/span&gt;: &lt;span style="color: #ea0008"&gt;@"%@%@"&lt;/span&gt;, [nformat &lt;span style="color: #470085"&gt;stringFromNumber&lt;/span&gt;: [&lt;span style="color: #7e1ead"&gt;NSNumber&lt;/span&gt; &lt;span style="color: #470085"&gt;numberWithDouble&lt;/span&gt;: doubleValue]]  , s] ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;span style="color: #d200a5"&gt;break&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;}&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;} &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[nformat &lt;span style="color: #470085"&gt;release&lt;/span&gt;] ; &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #470085"&gt;NSLog&lt;/span&gt;(&lt;span style="color: #ea0008"&gt;@"Value = %@"&lt;/span&gt;, stringValue);&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color: #d200a5"&gt;return&lt;/span&gt; stringValue ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input :&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #1a5b5e"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: #d200a5"&gt;self&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;formatCurrencyValue&lt;span style="color: #000000"&gt;: &lt;/span&gt;&lt;span style="color: #3700de"&gt;1235.0f&lt;/span&gt;&lt;span style="color: #000000"&gt;] ;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #1a5b5e"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: #d200a5"&gt;self&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;formatCurrencyValue&lt;span style="color: #000000"&gt;: &lt;/span&gt;&lt;span style="color: #3700de"&gt;10351.0f&lt;/span&gt;&lt;span style="color: #000000"&gt;] ;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #1a5b5e"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: #d200a5"&gt;self&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;formatCurrencyValue&lt;span style="color: #000000"&gt;: &lt;/span&gt;&lt;span style="color: #3700de"&gt;100522.0f&lt;/span&gt;&lt;span style="color: #000000"&gt;] ;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #1a5b5e"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: #d200a5"&gt;self&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;formatCurrencyValue&lt;span style="color: #000000"&gt;: &lt;/span&gt;&lt;span style="color: #3700de"&gt;1235111.0f&lt;/span&gt;&lt;span style="color: #000000"&gt;] ;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #1a5b5e"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: #d200a5"&gt;self&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;formatCurrencyValue&lt;span style="color: #000000"&gt;: &lt;/span&gt;&lt;span style="color: #3700de"&gt;12351234.0f&lt;/span&gt;&lt;span style="color: #000000"&gt;] ;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #1a5b5e"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: #d200a5"&gt;self&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;formatCurrencyValue&lt;span style="color: #000000"&gt;: &lt;/span&gt;&lt;span style="color: #3700de"&gt;192351234.0f&lt;/span&gt;&lt;span style="color: #000000"&gt;] ;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #1a5b5e"&gt;&lt;span style="color: #000000"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: #d200a5"&gt;self&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;/span&gt;formatCurrencyValue&lt;span style="color: #000000"&gt;: &lt;/span&gt;&lt;span style="color: #3700de"&gt;1872351234.0f&lt;/span&gt;&lt;span style="color: #000000"&gt;] ;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #000000"&gt;Output :&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #000000"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;b&gt;Value = £1.24k&lt;/b&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;b&gt;Value = £10.35k&lt;/b&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;b&gt;Value = £101k&lt;/b&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;b&gt;Value = £1.24m&lt;/b&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;b&gt;Value = £12.35m&lt;/b&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;b&gt;Value = £192.35m&lt;/b&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;b&gt;Value = £1.87b&lt;/b&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;b&gt;Note : you can add additional parameters to the function like number of fraction digits&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-2926166611705296303?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/2926166611705296303/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2010/08/nsnumberformatter-for-special-currency.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/2926166611705296303?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/2926166611705296303?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2010/08/nsnumberformatter-for-special-currency.html" title="NSNumberformatter for special currency formats" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkMFRns8fip7ImA9Wx9RFUo.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-6661106990758743015</id><published>2010-08-05T01:57:00.001-07:00</published><updated>2010-12-17T01:33:37.576-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-17T01:33:37.576-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="telemeter" /><category scheme="http://www.blogger.com/atom/ns#" term="telenet" /><category scheme="http://www.blogger.com/atom/ns#" term="ios" /><category scheme="http://www.blogger.com/atom/ns#" term="IPhone" /><title>Telenet telemeter for iPhone/iPod</title><content type="html">The telenet telemeter is now also available for the &lt;a href="http://itunes.apple.com/be/app/itelemeter/id384334571?mt=8"&gt;iPhone&lt;/a&gt; .&lt;br /&gt;&lt;div&gt;Some screenshots :&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img id="BLOGGER_PHOTO_ID_5501847848116020338" style="WIDTH: 214px; CURSOR: hand; HEIGHT: 320px" alt="" src="http://3.bp.blogspot.com/_TZ3tQh6tzPI/TFp9d8Mz5HI/AAAAAAAAAJc/WKRAGM3BmI0/s320/Screenshot+2010.07.25+13.48.59.png" border="0" /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;(Image below is from version 1.1, supports turbonet and fibernet)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img id="BLOGGER_PHOTO_ID_5501848047639032002" style="WIDTH: 214px; CURSOR: hand; HEIGHT: 320px" alt="" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/TFp9pjezcMI/AAAAAAAAAJk/OMY688wUzCY/s320/Screenshot+2010.08.04+13.33.53.png" border="0" /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-6661106990758743015?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/6661106990758743015/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2010/08/telenet-telemeter-for-iphoneipod.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/6661106990758743015?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/6661106990758743015?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2010/08/telenet-telemeter-for-iphoneipod.html" title="Telenet telemeter for iPhone/iPod" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_TZ3tQh6tzPI/TFp9d8Mz5HI/AAAAAAAAAJc/WKRAGM3BmI0/s72-c/Screenshot+2010.07.25+13.48.59.png" height="72" width="72" /><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;CkIBSHY6fip7ImA9Wx5SEE0.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-5000536540367245409</id><published>2010-07-31T03:00:00.000-07:00</published><updated>2010-08-05T02:29:19.816-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-08-05T02:29:19.816-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="text" /><category scheme="http://www.blogger.com/atom/ns#" term="pie chart" /><title>Drawing text on a pie chart (Cocoa)</title><content type="html">Drawing text along side a pie chart (see image below) is fairly simple :&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 120px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/TFP0xceCIUI/AAAAAAAAAJM/dspyJnsdbXo/s320/Schermafbeelding+2010-07-31+om+12.01.47.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5500008700242436418" /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You only need a bit of math.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let's look a some code :&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First you have your text :&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color:#7e1ead;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;NSDictionary&lt;span style="color:#000000;"&gt; *attributes = [&lt;/span&gt;NSDictionary&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#470085;"&gt;dictionaryWithObjectsAndKeys&lt;/span&gt;&lt;span style="color:#000000;"&gt;:[&lt;/span&gt;NSFont&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#470085;"&gt;fontWithName&lt;/span&gt;&lt;span style="color:#000000;"&gt;:&lt;/span&gt;&lt;span style="color:#ea0008;"&gt;@"Helvetica"&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#470085;"&gt;size&lt;/span&gt;&lt;span style="color:#000000;"&gt;:&lt;/span&gt;&lt;span style="color:#3700de;"&gt;12&lt;/span&gt;&lt;span style="color:#000000;"&gt;], &lt;/span&gt;NSFontAttributeName&lt;span style="color:#000000;"&gt;,[&lt;/span&gt;NSColor&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#470085;"&gt;blackColor&lt;/span&gt;&lt;span style="color:#000000;"&gt;], &lt;/span&gt;NSForegroundColorAttributeName&lt;span style="color:#000000;"&gt;,  &lt;/span&gt;&lt;span style="color:#d200a5;"&gt;nil&lt;/span&gt;&lt;span style="color:#000000;"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#7e1ead;"&gt;NSAttributedString&lt;/span&gt; * currentText=[[&lt;span style="color:#7e1ead;"&gt;NSAttributedString&lt;/span&gt; &lt;span style="color:#470085;"&gt;alloc&lt;/span&gt;] &lt;span style="color:#470085;"&gt;initWithString&lt;/span&gt;: @"some text" &lt;span style="color:#470085;"&gt;attributes&lt;/span&gt;: attributes];&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Then you need to figure out where you will put the text :&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;dot = &lt;span style="color:#470085;"&gt;NSMakePoint&lt;/span&gt;( size_x/&lt;span style="color:#3700de;"&gt;2&lt;/span&gt; + &lt;span style="color:#470085;"&gt;cos&lt;/span&gt; (&lt;span style="color:#824526;"&gt;PI&lt;/span&gt; * mid_angle / &lt;span style="color:#3700de;"&gt;180&lt;/span&gt; ) * &lt;span style="color:#3700de;"&gt;50&lt;/span&gt;   , size_y/&lt;span style="color:#3700de;"&gt;2&lt;/span&gt; + &lt;span style="color:#470085;"&gt;sin&lt;/span&gt; ( &lt;span style="color:#824526;"&gt;PI&lt;/span&gt; * mid_angle / &lt;span style="color:#3700de;"&gt;180&lt;/span&gt; ) * &lt;span style="color:#3700de;"&gt;50&lt;/span&gt;  ) ;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color:#470085;"&gt;&lt;span style="color:#000000;"&gt; &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[greenPath &lt;/span&gt;appendBezierPathWithArcWithCenter&lt;span style="color:#000000;"&gt;: dot &lt;/span&gt;radius&lt;span style="color:#000000;"&gt;: &lt;/span&gt;&lt;span style="color:#3700de;"&gt;2&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;startAngle&lt;span style="color:#000000;"&gt;: &lt;/span&gt;&lt;span style="color:#3700de;"&gt;0&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;endAngle&lt;span style="color:#000000;"&gt;: &lt;/span&gt;&lt;span style="color:#3700de;"&gt;360&lt;/span&gt;&lt;span style="color:#000000;"&gt; ] ; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:medium;"&gt;(This is the dot you see in the picture above)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:medium;"&gt;The mid_angle is the angle of slice divided by 2.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:medium;"&gt;Then you draw the text :&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:medium;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;        &lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;        textStartPoint = &lt;span style="color:#1a5b5e;"&gt;makeTextStartingPoint&lt;/span&gt;( [currentText &lt;span style="color:#470085;"&gt;size&lt;/span&gt;], bounds , mid_angle, &lt;span style="color:#3700de;"&gt;50&lt;/span&gt; ) ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[currentText &lt;span style="color:#470085;"&gt;drawAtPoint&lt;/span&gt;:textStartPoint];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt; &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;The function makeTextStartingPoint looks like follows :&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;NSPoint makeTextStartingPoint( &lt;span style="color:#7e1ead;"&gt;NSSize&lt;/span&gt; textSize, &lt;span style="color:#7e1ead;"&gt;NSRect&lt;/span&gt; bounds , &lt;span style="color:#d200a5;"&gt;float&lt;/span&gt; angle, &lt;span style="color:#d200a5;"&gt;int&lt;/span&gt; offset )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#7e1ead;"&gt;NSPoint&lt;/span&gt; textStartPoint ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#d200a5;"&gt;float&lt;/span&gt; size_x = bounds.&lt;span style="color:#7e1ead;"&gt;size&lt;/span&gt;.&lt;span style="color:#7e1ead;"&gt;width&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#d200a5;"&gt;float&lt;/span&gt; size_y = bounds.&lt;span style="color:#7e1ead;"&gt;size&lt;/span&gt;.&lt;span style="color:#7e1ead;"&gt;height&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#d200a5;"&gt;float&lt;/span&gt; angle_radian = &lt;span style="color:#824526;"&gt;PI&lt;/span&gt; * angle / &lt;span style="color:#3700de;"&gt;180&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#d200a5;"&gt;if&lt;/span&gt; ( angle &lt;= &lt;span style="color:#3700de;"&gt;90&lt;/span&gt; )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;textStartPoint = &lt;span style="color:#470085;"&gt;NSMakePoint&lt;/span&gt;( size_x/&lt;span style="color:#3700de;"&gt;2&lt;/span&gt; + &lt;span style="color:#470085;"&gt;cos&lt;/span&gt; (angle_radian) * offset + &lt;span style="color:#3700de;"&gt;5&lt;/span&gt; , size_y/&lt;span style="color:#3700de;"&gt;2&lt;/span&gt; + &lt;span style="color:#470085;"&gt;sin&lt;/span&gt; (angle_radian ) * offset  ) ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#d200a5;"&gt;if&lt;/span&gt; ( angle &gt; &lt;span style="color:#3700de;"&gt;90&lt;/span&gt;  &amp;amp;&amp;amp; angle &lt;= &lt;span style="color:#3700de;"&gt;180&lt;/span&gt;)&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;textStartPoint = &lt;span style="color:#470085;"&gt;NSMakePoint&lt;/span&gt;( size_x/&lt;span style="color:#3700de;"&gt;2&lt;/span&gt; + &lt;span style="color:#470085;"&gt;cos&lt;/span&gt; ( angle_radian ) * offset - textSize.&lt;span style="color:#7e1ead;"&gt;width&lt;/span&gt; - &lt;span style="color:#3700de;"&gt;5&lt;/span&gt; , size_y/&lt;span style="color:#3700de;"&gt;2&lt;/span&gt; + &lt;span style="color:#470085;"&gt;sin&lt;/span&gt; (angle_radian ) * offset  ) ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#d200a5;"&gt;if&lt;/span&gt; ( angle &gt; &lt;span style="color:#3700de;"&gt;180&lt;/span&gt; &amp;amp;&amp;amp; angle &lt;= &lt;span style="color:#3700de;"&gt;270&lt;/span&gt; )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;textStartPoint = &lt;span style="color:#470085;"&gt;NSMakePoint&lt;/span&gt;( size_x/&lt;span style="color:#3700de;"&gt;2&lt;/span&gt; + &lt;span style="color:#470085;"&gt;cos&lt;/span&gt; ( angle_radian  ) * offset - textSize.&lt;span style="color:#7e1ead;"&gt;width&lt;/span&gt; - &lt;span style="color:#3700de;"&gt;5&lt;/span&gt;, size_y/&lt;span style="color:#3700de;"&gt;2&lt;/span&gt; + &lt;span style="color:#470085;"&gt;sin&lt;/span&gt; ( angle_radian ) * offset - textSize.&lt;span style="color:#7e1ead;"&gt;height&lt;/span&gt; ) ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#d200a5;"&gt;if&lt;/span&gt; ( angle &gt; &lt;span style="color:#3700de;"&gt;270&lt;/span&gt; )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;textStartPoint = &lt;span style="color:#470085;"&gt;NSMakePoint&lt;/span&gt;( size_x/&lt;span style="color:#3700de;"&gt;2&lt;/span&gt; + &lt;span style="color:#470085;"&gt;cos&lt;/span&gt; ( angle_radian ) * offset + &lt;span style="color:#3700de;"&gt;8&lt;/span&gt; , size_y/&lt;span style="color:#3700de;"&gt;2&lt;/span&gt; + &lt;span style="color:#470085;"&gt;sin&lt;/span&gt; (angle_radian ) * offset - textSize.&lt;span style="color:#7e1ead;"&gt;height&lt;/span&gt;  ) ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#d200a5;"&gt;return&lt;/span&gt; textStartPoint ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:medium;"&gt;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.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"&gt;&lt;span class="Apple-style-span"  style="font-family:'times new roman';"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-5000536540367245409?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/5000536540367245409/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2010/07/drawing-text-on-pie-chart-cocoa.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/5000536540367245409?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/5000536540367245409?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2010/07/drawing-text-on-pie-chart-cocoa.html" title="Drawing text on a pie chart (Cocoa)" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_TZ3tQh6tzPI/TFP0xceCIUI/AAAAAAAAAJM/dspyJnsdbXo/s72-c/Schermafbeelding+2010-07-31+om+12.01.47.png" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkMHSHk-fip7ImA9Wx5SEE0.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-6086951137786308255</id><published>2010-06-21T08:35:00.000-07:00</published><updated>2010-08-05T02:27:19.756-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-08-05T02:27:19.756-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="technical analysis" /><category scheme="http://www.blogger.com/atom/ns#" term="portfolio management systems" /><category scheme="http://www.blogger.com/atom/ns#" term="isignals" /><category scheme="http://www.blogger.com/atom/ns#" term="quotes" /><category scheme="http://www.blogger.com/atom/ns#" term="ios" /><category scheme="http://www.blogger.com/atom/ns#" term="IPhone" /><category scheme="http://www.blogger.com/atom/ns#" term="itunes" /><title>iSignals v2.0.2</title><content type="html">&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Version 2.0.2 of iSignals is finally landed !&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;It's now compatible with iOS4,  contains a subscription store,  contains a lot of technical analysis charts etc.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The application supports MACD, MFI, EMA, SMA,TMA, Parabolic SAR, Bollingerbands,ROC, RSI, Slow and fast stochastic, Williams %R and the Chaikin Osscilator?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Some screenshots :&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/TFqCoOoYNUI/AAAAAAAAAJ0/rnwKChTxMVQ/s320/Screenshot+2009.12.14+21.11.51.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5501853522420315458" /&gt;&lt;/span&gt;&lt;img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/TFqCo7HxWGI/AAAAAAAAAKM/gN-EMA1cuao/s320/Screenshot+2009.12.18+10.06.03.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5501853534363146338" /&gt;&lt;img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/TFqCoVCfSzI/AAAAAAAAAJ8/iQDO63665Y8/s320/Screenshot+2009.12.14+21.12.40.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5501853524140444466" /&gt;&lt;img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="http://3.bp.blogspot.com/_TZ3tQh6tzPI/TFqCorNgLGI/AAAAAAAAAKE/kCR1T8kl8vI/s320/Screenshot+2010.06.13+12.57.25.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5501853530092219490" /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Have look : &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:Arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;URL : &lt;/span&gt;&lt;a href="http://itunes.apple.com/us/app/isignals/id328171880?mt=8"&gt;&lt;span style="text-decoration: underline"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;http://itunes.apple.com/us/app/isignals/id328171880?mt=8&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Times New Roman'; min-height: 15.0px"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Arial; color:#110097;"&gt;&lt;span class="Apple-style-span"  style="font-family:'Times New Roman';"&gt;&lt;span class="Apple-style-span"  style="font-family:Arial;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Instruction video of iSignals : &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://www.youtube.com/watch?v=fd9nrEr-r7E"&gt;&lt;span style="text-decoration: underline; "&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;http://www.youtube.com/watch?v=fd9nrEr-r7E&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Arial; color:#110097;"&gt;&lt;span class="Apple-style-span"  style="font-family:'Times New Roman';"&gt;&lt;span class="Apple-style-span"  style="font-family:Arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Arial; color:#110097;"&gt;&lt;span class="Apple-style-span"  style="font-family:'Times New Roman';"&gt;&lt;span class="Apple-style-span"  style="font-family:Arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Times New Roman'; min-height: 15.0px"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-6086951137786308255?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/6086951137786308255/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2010/06/some-publicity-for-myself.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/6086951137786308255?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/6086951137786308255?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2010/06/some-publicity-for-myself.html" title="iSignals v2.0.2" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_TZ3tQh6tzPI/TFqCoOoYNUI/AAAAAAAAAJ0/rnwKChTxMVQ/s72-c/Screenshot+2009.12.14+21.11.51.png" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUANSHk-eSp7ImA9WxBQGE0.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-8746770746519242682</id><published>2010-01-15T06:47:00.000-08:00</published><updated>2010-01-18T00:36:39.751-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-18T00:36:39.751-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="checkbox" /><category scheme="http://www.blogger.com/atom/ns#" term="radiobutton" /><category scheme="http://www.blogger.com/atom/ns#" term="IPhone" /><category scheme="http://www.blogger.com/atom/ns#" term="UISegmentedControl" /><category scheme="http://www.blogger.com/atom/ns#" term="UiSegment" /><title>a UISegmentedControl subclass that simulates checkboxes</title><content type="html">I would like to share a small , possible, implementation of checkboxes on the iPhone using a UISegmentedControl subclass.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The UISegmentedControl is in fact a radiobutton over multiple possibilities, now in certain circumstances it could be usefull that you can select multiple items.&lt;/div&gt;&lt;div&gt;One possibility is to use a tableview, however in some cases this is overkill.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Suppose you have the following selection list :&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 208px; height: 39px;" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/S1CBcosBJxI/AAAAAAAAAH4/GZVYCUvvp1M/s320/Afbeelding+1.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5426979879939811090" /&gt;&lt;/div&gt;&lt;div&gt;In this list you want to be able to select multiple values like this (for example) :&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 210px; height: 44px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/S1CBviAwmVI/AAAAAAAAAIA/XB4hKxgzo7o/s320/Afbeelding+2.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5426980204565272914" /&gt;&lt;/div&gt;&lt;div&gt;Now to be able to do this , I wrote a small subclass of UISegmentedControl :&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"&gt;&lt;span style="color:#643820;"&gt;#import &lt;/span&gt;&lt;uikit/uikit.h&gt;&lt;/uikit/uikit.h&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span style="color:#aa0d91;"&gt;@interface&lt;/span&gt; UIMultipleSelectionSegmentControl : UISegmentedControl  {&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#5c2699;"&gt;NSMutableSet&lt;/span&gt;  *indices ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;@property&lt;span style="color:#000000;"&gt;( &lt;/span&gt;nonatomic&lt;span style="color:#000000;"&gt;,&lt;/span&gt;retain&lt;span style="color:#000000;"&gt;)   &lt;/span&gt;&lt;span style="color:#5c2699;"&gt;NSMutableSet&lt;/span&gt;&lt;span style="color:#000000;"&gt; *indices ;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;  &lt;/p&gt; &lt;p color="#aa0d91" style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; "&gt;@end&lt;/p&gt;&lt;p color="#aa0d91" style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; "&gt;&lt;br /&gt;&lt;/p&gt;&lt;p color="#aa0d91" style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; "&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;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 .&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"&gt;&lt;span style="color:#643820;"&gt;#import &lt;/span&gt;"UIMultipleSelectionSegmentControl.h"&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span style="color:#aa0d91;"&gt;@implementation&lt;/span&gt; UIMultipleSelectionSegmentControl&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt; &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91"&gt;@synthesize&lt;span style="color:#000000;"&gt; indices ;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt; &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt; &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color:#5c2699;"&gt;NSSet&lt;/span&gt; *) selectedSegmentIndices&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;return&lt;span style="color:#000000;"&gt; &lt;/span&gt;self&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;indices&lt;/span&gt;&lt;span style="color:#000000;"&gt; ;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color:#aa0d91;"&gt;void&lt;/span&gt;) setSelectedSegmentIndices: (&lt;span style="color:#5c2699;"&gt;NSSet&lt;/span&gt; *) aSet&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#5c2699;"&gt;NSEnumerator&lt;/span&gt; *enumerator = [aSet &lt;span style="color:#2e0d6e;"&gt;objectEnumerator&lt;/span&gt;];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#5c2699;"&gt;NSNumber&lt;/span&gt; *value;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;while&lt;/span&gt; ((value = [enumerator &lt;span style="color:#2e0d6e;"&gt;nextObject&lt;/span&gt;])) &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;[&lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;setSelectedSegmentIndex&lt;span style="color:#000000;"&gt;: [value &lt;/span&gt;integerValue&lt;span style="color:#000000;"&gt;]] ;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color:#aa0d91;"&gt;void&lt;/span&gt;) setSelectedSegmentIndex: (&lt;span style="color:#5c2699;"&gt;NSInteger&lt;/span&gt;) anIndex&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;if&lt;/span&gt; ( &lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;.indices == &lt;span style="color:#aa0d91;"&gt;nil&lt;/span&gt; ) &lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;.indices = [&lt;span style="color:#5c2699;"&gt;NSMutableSet&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;set&lt;/span&gt;] ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;if&lt;/span&gt; ( anIndex &gt;= &lt;span style="color:#1c00cf;"&gt;0&lt;/span&gt; )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#5c2699;"&gt;NSNumber&lt;/span&gt; *indexNumber ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; *myImage ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;indexNumber = [&lt;span style="color:#5c2699;"&gt;NSNumber&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;numberWithInt&lt;/span&gt;: anIndex] ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;if&lt;/span&gt; ( ! [&lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;.indices &lt;span style="color:#2e0d6e;"&gt;containsObject&lt;/span&gt;: indexNumber] )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;[&lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;.indices &lt;span style="color:#2e0d6e;"&gt;addObject&lt;/span&gt;: indexNumber] ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;switch&lt;/span&gt;( anIndex )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;0&lt;/span&gt; :myImage = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;: &lt;span style="color:#c41a16;"&gt;@"segment-5-sel.png"&lt;/span&gt;] ; &lt;span style="color:#aa0d91;"&gt;break&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;1&lt;/span&gt; :myImage = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;: &lt;span style="color:#c41a16;"&gt;@"segment-10-sel.png"&lt;/span&gt;] ; &lt;span style="color:#aa0d91;"&gt;break&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;2&lt;/span&gt; :myImage = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;: &lt;span style="color:#c41a16;"&gt;@"segment-20-sel.png"&lt;/span&gt;] ; &lt;span style="color:#aa0d91;"&gt;break&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;3&lt;/span&gt; :myImage = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;: &lt;span style="color:#c41a16;"&gt;@"segment-50-sel.png"&lt;/span&gt;] ; &lt;span style="color:#aa0d91;"&gt;break&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;4&lt;/span&gt; :myImage = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;: &lt;span style="color:#c41a16;"&gt;@"segment-100-sel.png"&lt;/span&gt;] ; &lt;span style="color:#aa0d91;"&gt;break&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;5&lt;/span&gt;: myImage = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;: &lt;span style="color:#c41a16;"&gt;@"segment-200-sel.png"&lt;/span&gt;] ; &lt;span style="color:#aa0d91;"&gt;break&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;}&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;[&lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;super&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;setSelectedSegmentIndex&lt;span style="color:#000000;"&gt;: anIndex] ;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;{&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt; &lt;/span&gt;  [&lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt;.indices &lt;span style="color:#2e0d6e;"&gt;removeObject&lt;/span&gt;: indexNumber] ;&lt;br /&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;[&lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;super&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;setSelectedSegmentIndex&lt;span style="color:#000000;"&gt;: -&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span" style="color: rgb(28, 0, 207);"&gt;indexNumber&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;] ;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;switch&lt;/span&gt;( anIndex )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;0&lt;/span&gt; :myImage = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;: &lt;span style="color:#c41a16;"&gt;@"segment-5.png"&lt;/span&gt;] ; &lt;span style="color:#aa0d91;"&gt;break&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;1&lt;/span&gt; :myImage = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;: &lt;span style="color:#c41a16;"&gt;@"segment-10.png"&lt;/span&gt;] ; &lt;span style="color:#aa0d91;"&gt;break&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;2&lt;/span&gt; :myImage = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;: &lt;span style="color:#c41a16;"&gt;@"segment-20.png"&lt;/span&gt;] ; &lt;span style="color:#aa0d91;"&gt;break&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;3&lt;/span&gt; :myImage = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;: &lt;span style="color:#c41a16;"&gt;@"segment-50.png"&lt;/span&gt;] ; &lt;span style="color:#aa0d91;"&gt;break&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;4&lt;/span&gt; :myImage = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;: &lt;span style="color:#c41a16;"&gt;@"segment-100.png"&lt;/span&gt;] ; &lt;span style="color:#aa0d91;"&gt;break&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;    &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;case&lt;/span&gt; &lt;span style="color:#1c00cf;"&gt;5&lt;/span&gt;: myImage = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;: &lt;span style="color:#c41a16;"&gt;@"segment-200.png"&lt;/span&gt;] ; &lt;span style="color:#aa0d91;"&gt;break&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;[&lt;span style="color:#aa0d91;"&gt;self&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;setImage&lt;/span&gt;: myImage &lt;span style="color:#2e0d6e;"&gt;forSegmentAtIndex&lt;/span&gt;: anIndex] ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt; &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;    }&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color:#aa0d91;"&gt;void&lt;/span&gt;)dealloc {&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;    [indices &lt;span style="color:#2e0d6e;"&gt;release&lt;/span&gt;] ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;    [&lt;span style="color:#aa0d91;"&gt;super&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;dealloc&lt;/span&gt;];&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91"&gt;@end&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(170, 13, 145);  font-family:Monaco;font-size:10px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In this case I made images of each segment, one that represent the unselected image and one the represent the selected image.&lt;/div&gt;&lt;div&gt;(the images in my case are 24x24 pixels in size).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This subclass will still send UIControlChangeEvents, so it acts as a normal UIControl class.&lt;/div&gt;&lt;div&gt;To get the indices you have to call the method selectedSegmentIndices and to set them you use setSelectedSegmentIndices:.&lt;/div&gt;&lt;div&gt;(note that the indices are a NSSet).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-8746770746519242682?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/8746770746519242682/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2010/01/uisegmentedcontrol-subclass-that.html#comment-form" title="7 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/8746770746519242682?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/8746770746519242682?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2010/01/uisegmentedcontrol-subclass-that.html" title="a UISegmentedControl subclass that simulates checkboxes" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_TZ3tQh6tzPI/S1CBcosBJxI/AAAAAAAAAH4/GZVYCUvvp1M/s72-c/Afbeelding+1.png" height="72" width="72" /><thr:total>7</thr:total></entry><entry gd:etag="W/&quot;CEcMQn85cSp7ImA9WxBSGU8.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-6980713734627212029</id><published>2009-12-27T04:41:00.000-08:00</published><updated>2009-12-27T05:54:43.129-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-27T05:54:43.129-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="appstore" /><category scheme="http://www.blogger.com/atom/ns#" term="apps" /><category scheme="http://www.blogger.com/atom/ns#" term="IPhone" /><category scheme="http://www.blogger.com/atom/ns#" term="finance" /><category scheme="http://www.blogger.com/atom/ns#" term="sales" /><category scheme="http://www.blogger.com/atom/ns#" term="apple" /><title>Apple's AppStore a goldmine or ...</title><content type="html">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.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;Let's go over the timeline from concept of the app until today.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-large;"&gt;1. Concept&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Of course this was not a game so we wouldn't reach the masses or getting great attention from review sites etc.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;(Note: I still find it strange that people buy 600 USdollars phones to play games on it, but oke).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-large;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;2. Development&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;That was a strange experience for a non-US citizen ;-).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Apparently they don't believe in the Internet because the only to get that number was by phone, mail or fax - no online -.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Anyway we start coding , he was using PHP for the backend and I using Objective-C for the front-end.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It took about 2,5 months to develop it, 1 month beta-testing and 1 month for corrections, change requests etc.&lt;/div&gt;&lt;div&gt;So in August 2009 I submitted the app for approval to ItunesConnect. And now the story begins...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-large;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;3. Approval process&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now that was wrong.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;So august went by -&gt; no approval&lt;/div&gt;&lt;div&gt;September went by -&gt; no approval (and no message from Apple)&lt;/div&gt;&lt;div&gt;October went by -&gt; no approval (no message from Apple).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;At that time I sent an email to them but I got a standard response back.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;I quickly fixed it and resubmitted it, and I was afraid that it would take again 3,5 months for approval.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But luckily for one reason or another they almost immediatly reviewed it and approved it.&lt;/div&gt;&lt;div&gt;So since December 3th the application is on the AppStore for sale !&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-large;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;4. Post Natal depression&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So the new born is 1 month old, and how is the sales going ?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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).&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Conclusion : creating and developing an application for the iPhone is the easy part , its 10 % of the effort , marketing is the other 90%.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-6980713734627212029?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/6980713734627212029/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/12/apples-appstore-goldmine-or.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/6980713734627212029?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/6980713734627212029?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/12/apples-appstore-goldmine-or.html" title="Apple's AppStore a goldmine or ..." /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkUCRH47eip7ImA9WxBQEk8.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-7540792899105539547</id><published>2009-12-26T06:51:00.000-08:00</published><updated>2010-01-11T06:31:05.002-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-11T06:31:05.002-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="CGPath" /><category scheme="http://www.blogger.com/atom/ns#" term="UIView" /><category scheme="http://www.blogger.com/atom/ns#" term="text" /><category scheme="http://www.blogger.com/atom/ns#" term="drawrect" /><category scheme="http://www.blogger.com/atom/ns#" term="font" /><category scheme="http://www.blogger.com/atom/ns#" term="graphics" /><category scheme="http://www.blogger.com/atom/ns#" term="drawing" /><category scheme="http://www.blogger.com/atom/ns#" term="Graphics context" /><title>drawing graphics for the iPhone (not opengl ES)</title><content type="html">Don't we all want to make graphics like this : ?&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 176px; height: 320px;" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SzYjlG4dr8I/AAAAAAAAAHw/bORYKLAHnvM/s320/Afbeelding+12.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5419558321996541890" /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;Well , I'll try to explain how I did this (BTW this graphics comes from my iphone application &lt;a href="http://itunes.apple.com/be/app/isignals/id328171880?mt=8"&gt;iSignals)&lt;/a&gt;.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;First create a file in your project which is a subclass of UIView (via XCode&gt;File&gt;New File). Call it for example MyGraphView. &lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;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.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;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[].&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;So let's see how the drawRect method is implemented.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;- (&lt;span style="color:#aa0d91;"&gt;void&lt;/span&gt;)drawRect:(&lt;span style="color:#5c2699;"&gt;CGRect&lt;/span&gt;)rect {&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"&gt;&lt;span style="color:#000000;"&gt;    &lt;/span&gt;// Drawing code&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 116, 0);  font-family:Monaco;font-size:10px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;float&lt;/span&gt; width =  rect.&lt;span style="color:#5c2699;"&gt;size&lt;/span&gt;.&lt;span style="color:#5c2699;"&gt;width&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;float&lt;/span&gt; height = rect.&lt;span style="color:#5c2699;"&gt;size&lt;/span&gt;.&lt;span style="color:#5c2699;"&gt;height&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#5c2699;"&gt;CGContextRef&lt;/span&gt; currentContext ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;int&lt;/span&gt; i = &lt;span style="color:#1c00cf;"&gt;0&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;span class="Apple-style-span" style="color: rgb(0, 116, 0); "&gt;// Get the graphics context that we are currently executing under&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;currentContext = &lt;/span&gt;UIGraphicsGetCurrentContext&lt;span style="color:#000000;"&gt;() ;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"&gt;&lt;span style="color:#000000;"&gt;   ;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span" style="font-family: 'times new roman'; font-size: 48px;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;In the first lines of the drawRect, I save the width and the height, I'll use this to calculate the scale factors.&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;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.&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;But of course what more important is , is the world coordinatessystem. And these coordinates are the coordinates of your world.&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;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).&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;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.&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#643820;"&gt;#define OFFSET_X &lt;span style="color:#1c00cf;"&gt;30.0f&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#643820;"&gt;#define OFFSET_Y &lt;span style="color:#1c00cf;"&gt;10.0f&lt;/span&gt; &lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(100, 56, 32);  font-family:Monaco;font-size:10px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;scale_factor_x&lt;/span&gt; = ( width -  &lt;span style="color:#643820;"&gt;OFFSET_X&lt;/span&gt; ) / ( [&lt;span style="color:#3f6e74;"&gt;dataPoints&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;count&lt;/span&gt;] - &lt;span style="color:#1c00cf;"&gt;0&lt;/span&gt; );&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;scale_factor_y&lt;/span&gt; =   (height - &lt;span style="color:#643820;"&gt;OFFSET_Y&lt;/span&gt; ) / (&lt;span style="color:#3f6e74;"&gt;max_y&lt;/span&gt; - &lt;span style="color:#3f6e74;"&gt;min_y&lt;/span&gt; ) ; // max_y = max(dataPoints) ;min_y = min(dataPoints)&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'times new roman';font-size:large;"&gt;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.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'times new roman';font-size:18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'times new roman';font-size:18px;"&gt;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.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'times new roman';font-size:18px;"&gt;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).&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'times new roman';font-size:18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'times new roman';font-size:18px;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;// draw the axes&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextSetRGBStrokeColor&lt;/span&gt;(currentContext, &lt;span style="color:#1c00cf;"&gt;0.83&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;0.83&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;0.83&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;0.7&lt;/span&gt;); // this is sort of gray&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextMoveToPoint&lt;/span&gt;( currentContext,   &lt;span style="color:#643820;"&gt;OFFSET_X&lt;/span&gt;, height - &lt;span style="color:#643820;"&gt;OFFSET_Y&lt;/span&gt;  );&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextAddLineToPoint&lt;/span&gt;( currentContext,   &lt;span style="color:#643820;"&gt;OFFSET_X&lt;/span&gt;, &lt;span style="color:#643820;"&gt;OFFSET_Y&lt;/span&gt; );&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextMoveToPoint&lt;/span&gt;( currentContext,   &lt;span style="color:#643820;"&gt;OFFSET_X&lt;/span&gt;, height - &lt;span style="color:#643820;"&gt;OFFSET_Y&lt;/span&gt;   );&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextAddLineToPoint&lt;/span&gt;( currentContext,   width, height - &lt;span style="color:#643820;"&gt;OFFSET_Y&lt;/span&gt;  );&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;CGContextStrokePath&lt;span style="color:#000000;"&gt;(currentContext);&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(46, 13, 110);"&gt; &lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'times new roman';font-size:large;"&gt;And draw some gridlines&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;        &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextSetRGBStrokeColor&lt;/span&gt;(currentContext, &lt;span style="color:#1c00cf;"&gt;0.83&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;0.83&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;0.83&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;1&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#5c2699;"&gt;CGFloat&lt;/span&gt; len[] = {&lt;span style="color:#1c00cf;"&gt;4&lt;/span&gt;,&lt;span style="color:#1c00cf;"&gt;2&lt;/span&gt;} ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextSetLineDash&lt;/span&gt;( currentContext, &lt;span style="color:#1c00cf;"&gt;0&lt;/span&gt;, len, &lt;span style="color:#1c00cf;"&gt;2&lt;/span&gt; ) ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;    &lt;span style="color:#aa0d91;"&gt;for&lt;/span&gt; ( i = &lt;span style="color:#643820;"&gt;OFFSET_X&lt;/span&gt; ; i &lt;= height ; i = i + &lt;span style="color:#643820;"&gt;OFFSET_X&lt;/span&gt; )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextMoveToPoint&lt;/span&gt;( currentContext,   &lt;span style="color:#643820;"&gt;OFFSET_X&lt;/span&gt;, height - &lt;span style="color:#643820;"&gt;OFFSET_Y&lt;/span&gt; - i );&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextAddLineToPoint&lt;/span&gt;( currentContext,   width, height - &lt;span style="color:#643820;"&gt;OFFSET_Y&lt;/span&gt; - i);&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;CGContextStrokePath&lt;span style="color:#000000;"&gt;(currentContext);&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(46, 13, 110);"&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;And then draw the graph of datapoints&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;  &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextSetRGBStrokeColor&lt;/span&gt;(currentContext, &lt;span style="color:#1c00cf;"&gt;1.0&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;0.65&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;0&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;1&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;    &lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; *red = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;: &lt;span style="color:#c41a16;"&gt;@"red.png"&lt;/span&gt;] ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; *green = [&lt;span style="color:#5c2699;"&gt;UIImage&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;imageNamed&lt;/span&gt;: &lt;span style="color:#c41a16;"&gt;@"green.png"&lt;/span&gt;] ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#5c2699;"&gt;CGPoint&lt;/span&gt; aPoint ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;// draw the history graph&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;for&lt;/span&gt;( i = &lt;span style="color:#1c00cf;"&gt;0&lt;/span&gt; ; i&lt; [&lt;span style="color:#3f6e74;"&gt;dataPoints&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;count&lt;/span&gt;] ; i++ )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;x =  &lt;span style="color:#643820;"&gt;OFFSET_X&lt;/span&gt; +    i * &lt;span style="color:#3f6e74;"&gt;scale_factor_x&lt;/span&gt; ;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;old_y = [[&lt;/span&gt;&lt;span style="color:#3f6e74;"&gt;dataPoints&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;objectAtIndex&lt;span style="color:#000000;"&gt;: i] &lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;floatValue&lt;span style="color:#000000;"&gt;];&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;y =   (height -&lt;span style="color:#643820;"&gt;OFFSET_Y&lt;/span&gt;) - ([[&lt;span style="color:#3f6e74;"&gt;dataPoints&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;objectAtIndex&lt;/span&gt;: i]  &lt;span style="color:#2e0d6e;"&gt;floatValue&lt;/span&gt;] - &lt;span style="color:#3f6e74;"&gt;min_y&lt;/span&gt;) * &lt;span style="color:#3f6e74;"&gt;scale_factor_y&lt;/span&gt; ;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;if&lt;/span&gt; ( old_x &lt; &lt;span style="color:#1c00cf;"&gt;0&lt;/span&gt; )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextMoveToPoint&lt;/span&gt;( currentContext,   x, y  );&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;old_x = x ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;}&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;old_x = x ;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextAddLineToPoint&lt;/span&gt;( currentContext,   x, y );&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;}&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(170, 13, 145);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;CGContextStrokePath&lt;span style="color:#000000;"&gt;(currentContext);&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt; &lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'times new roman';font-size:large;"&gt;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).&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);  font-family:'times new roman';font-size:18px;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt; &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;        // this is for the font&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextSetRGBStrokeColor&lt;/span&gt;(currentContext, &lt;span style="color:#1c00cf;"&gt;1&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;1&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;1&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;1&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextSetRGBFillColor&lt;/span&gt;(currentContext, &lt;span style="color:#1c00cf;"&gt;1.0&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;1.0&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;1.0&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;0.8&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;CGContextSelectFont&lt;span style="color:#000000;"&gt;(&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;      &lt;/span&gt;currentContext,&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#c41a16;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;      &lt;/span&gt;&lt;/span&gt;"Helvetica-Bold"&lt;span style="color:#000000;"&gt;,&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#643820;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;      &lt;/span&gt;&lt;/span&gt;FONT_SIZE&lt;span style="color:#000000;"&gt;,&lt;/span&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;      &lt;/span&gt;&lt;/span&gt;kCGEncodingMacRoman&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;      &lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;        // this transformation is to make sure that the text is written in the right direction&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color:#5c2699;"&gt;CGAffineTransform&lt;/span&gt;&lt;span style="color:#000000;"&gt; transform = &lt;/span&gt;CGAffineTransformMake(&lt;span style="color:#000000;"&gt;&lt;span style="color:#1c00cf;"&gt;1.0&lt;/span&gt;,&lt;span style="color:#1c00cf;"&gt;0&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;0.0&lt;/span&gt;, -&lt;span style="color:#1c00cf;"&gt;1.0&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;0.0&lt;/span&gt;, &lt;span style="color:#1c00cf;"&gt;0.0&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); "&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;        &lt;span style="color:#2e0d6e;"&gt;CGContextSetTextMatrix&lt;/span&gt;(currentContext, transform);&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;CGContextSetTextDrawingMode&lt;span style="color:#000000;"&gt;(currentContext, &lt;/span&gt;kCGTextFill&lt;span style="color:#000000;"&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#2e0d6e;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#007400;"&gt;// set Y-labels&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;float&lt;/span&gt; j1 = &lt;span style="color:#3f6e74;"&gt;min_y&lt;/span&gt; ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;float&lt;/span&gt; step = (&lt;span style="color:#3f6e74;"&gt;max_y&lt;/span&gt; - &lt;span style="color:#3f6e74;"&gt;min_y&lt;/span&gt;)/ &lt;span style="color:#1c00cf;"&gt;7.0f&lt;/span&gt; ; // 7 labels&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;for&lt;/span&gt; ( i = &lt;span style="color:#1c00cf;"&gt;0.0f&lt;/span&gt; ; i &lt;=height ; i = i + &lt;span class="Apple-style-span" style="color: rgb(28, 0, 207);"&gt;OFFSET_X&lt;/span&gt; )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;// set the precision of the label&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span style="color:#aa0d91;"&gt;if&lt;/span&gt; ( j1 &gt; &lt;span style="color:#1c00cf;"&gt;999.0f&lt;/span&gt; )&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;    s1 = [&lt;span style="color:#5c2699;"&gt;NSString&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;stringWithFormat&lt;/span&gt;:&lt;span style="color:#c41a16;"&gt;@"%4.0f"&lt;/span&gt;, j1] ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;}&lt;/p&gt; &lt;p  style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color:#aa0d91;"&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;{&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;    s1 = [&lt;span style="color:#5c2699;"&gt;NSString&lt;/span&gt; &lt;span style="color:#2e0d6e;"&gt;stringWithFormat&lt;/span&gt;:&lt;span style="color:#c41a16;"&gt;@"%4.2f"&lt;/span&gt;, j1] ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;j1 += step ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span style="color:#2e0d6e;"&gt;CGContextShowTextAtPoint&lt;/span&gt;( currentContext,&lt;span style="color:#1c00cf;"&gt;0&lt;/span&gt; , height - &lt;span style="color:#643820;"&gt;OFFSET_Y&lt;/span&gt; - i , [s1 &lt;span style="color:#2e0d6e;"&gt;UTF8String&lt;/span&gt;] , [s1 &lt;span style="color:#2e0d6e;"&gt;length&lt;/span&gt;] ) ;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;}&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p color="#007400" style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; "&gt;&lt;span style="color:#000000;"&gt;   &lt;/span&gt;&lt;/p&gt; &lt;p color="#2e0d6e" style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; "&gt;&lt;span style="color:#000000;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;CGContextStrokePath&lt;span style="color:#000000;"&gt;(currentContext);&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p color="#2e0d6e" style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Voila this was it, next time I'll refactor the code and use Paths instead of each time saving and restoring the context&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"&gt; &lt;/p&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-7540792899105539547?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/7540792899105539547/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/12/drawing-graphics-for-iphone-not-opengl.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/7540792899105539547?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/7540792899105539547?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/12/drawing-graphics-for-iphone-not-opengl.html" title="drawing graphics for the iPhone (not opengl ES)" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SzYjlG4dr8I/AAAAAAAAAHw/bORYKLAHnvM/s72-c/Afbeelding+12.png" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;A0cMSHg9cCp7ImA9WxBSGE4.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-5302221632722726512</id><published>2009-12-04T00:09:00.000-08:00</published><updated>2009-12-26T06:51:29.668-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-26T06:51:29.668-08:00</app:edited><title>Its finally there</title><content type="html">After months of hard work and a long review process by Apple, my first iPhone application is finally accepted on the AppStore.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica"&gt;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. &lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica"&gt;On the daily basis the engine generates computer managed portfolios with buy&amp;amp;sells of those equities (portfolio's are organized per market).&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica"&gt;The engine is based on a combination of technical analysis models, artificial intelligence (pattern detection) and a neural network.&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica"&gt;Via iSignals the user can subscribe to one or more computer managed portfolio's and as such receiving the buy/sells from the engine.&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica"&gt;The user can now use those computer generated signals as a guidance in his investment decisions.&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica"&gt;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.&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica"&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;You can find it &lt;a href="http://itunes.apple.com/be/app/isignals/id328171880?mt=8"&gt;here&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-5302221632722726512?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/5302221632722726512/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/12/its-finally-there.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/5302221632722726512?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/5302221632722726512?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/12/its-finally-there.html" title="Its finally there" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkADQH4zfyp7ImA9WxJaEEk.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-3878759802953878924</id><published>2009-07-31T01:44:00.000-07:00</published><updated>2009-07-31T05:52:51.087-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-31T05:52:51.087-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sms hack" /><category scheme="http://www.blogger.com/atom/ns#" term="IPhone" /><title>iPhone SMS hack</title><content type="html">I 've downloaded the PDF file that explains in full detail the SMS hack.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can find it here : &lt;a href="http://www.box.net/shared/bydck05u5n"&gt;SMS hack.pdf&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now 4 caveats :&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1) They tested it in lab environment, so not by sending real SMS's over a carrier (because that cost money :-) )&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2) If some hacker really wants to exploit this he will need a lot of phonenumbers (and cash to send the SMS)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3) The hacker his identity will be quickly revealed as sending of SMS is not anonymous at all.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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 &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-3878759802953878924?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/3878759802953878924/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/07/iphone-sms-hack.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/3878759802953878924?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/3878759802953878924?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/07/iphone-sms-hack.html" title="iPhone SMS hack" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DU4ER3s7eCp7ImA9WxJbFU8.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-6206796640972535054</id><published>2009-07-25T06:17:00.000-07:00</published><updated>2009-07-25T06:18:26.500-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-25T06:18:26.500-07:00</app:edited><title>iPhone user experience</title><content type="html">For 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/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-6206796640972535054?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/6206796640972535054/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/07/iphone-user-experience.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/6206796640972535054?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/6206796640972535054?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/07/iphone-user-experience.html" title="iPhone user experience" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEMFSX05eCp7ImA9WxJbEUs.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-6089702312906644569</id><published>2009-07-21T00:34:00.000-07:00</published><updated>2009-07-21T00:46:58.320-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-21T00:46:58.320-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="user experience" /><category scheme="http://www.blogger.com/atom/ns#" term="NSThread" /><category scheme="http://www.blogger.com/atom/ns#" term="Cocoa Touch" /><category scheme="http://www.blogger.com/atom/ns#" term="iPhone OS" /><title>Multitasking for the iPhone: something simple</title><content type="html">We 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.&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;Of course this method only applies to tasks which takes 2-4 seconds , for longer tasks you'll need NSThread.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;In the mean time the implementation of the time consuming task I do in the &lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;viewDidAppear:&lt;/span&gt; method.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;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.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I found this much easier than going to the route of NSThread with all the difficulties of locking of shared variables etc.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-6089702312906644569?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/6089702312906644569/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/07/multitasking-for-iphone-something.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/6089702312906644569?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/6089702312906644569?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/07/multitasking-for-iphone-something.html" title="Multitasking for the iPhone: something simple" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CU8ASXY7eCp7ImA9WxJXGEQ.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-3773346837623391946</id><published>2009-06-13T04:42:00.000-07:00</published><updated>2009-06-13T04:50:48.800-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-13T04:50:48.800-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="trading" /><category scheme="http://www.blogger.com/atom/ns#" term="portfolio management systems" /><category scheme="http://www.blogger.com/atom/ns#" term="signals" /><category scheme="http://www.blogger.com/atom/ns#" term="IPhone" /><category scheme="http://www.blogger.com/atom/ns#" term="beta" /><title>IPhone application, iSignals, goes beta</title><content type="html">Oke, it's finally here ! My application goes in beta phase 1.&lt;div&gt;The purpose of the application is to have a portfolio management system with buy and sell signals generated by a backend.&lt;/div&gt;&lt;div&gt;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).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For more information please visit the &lt;a href="http://www.isignals.biz/"&gt;website&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Screenshots :&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/SjORvZwSPAI/AAAAAAAAAHA/F35_Zi55OEE/s320/Screenshot+2009.06.13+13.34.54.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5346777426172197890" /&gt;&lt;img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="http://3.bp.blogspot.com/_TZ3tQh6tzPI/SjOR9sfzaLI/AAAAAAAAAHI/SSD0QSVIWvk/s320/Screenshot+2009.06.13+13.35.03.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5346777671721511090" /&gt;&lt;img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="http://4.bp.blogspot.com/_TZ3tQh6tzPI/SjOR9wpDPSI/AAAAAAAAAHQ/qD-MGjCtHpE/s320/Screenshot+2009.06.13+13.35.10.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5346777672834039074" /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="http://4.bp.blogspot.com/_TZ3tQh6tzPI/SjOR97qP7nI/AAAAAAAAAHY/61HHmsuJTHQ/s320/Screenshot+2009.06.13+13.35.22.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5346777675791855218" /&gt;&lt;img style="cursor:pointer; cursor:hand;width: 214px; height: 320px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/SjOR-NDvqxI/AAAAAAAAAHg/A1BJqbSjHAM/s320/Screenshot+2009.06.13+13.35.39.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5346777680462195474" /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-3773346837623391946?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/3773346837623391946/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/06/iphone-application-isignals-goes-beta.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/3773346837623391946?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/3773346837623391946?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/06/iphone-application-isignals-goes-beta.html" title="IPhone application, iSignals, goes beta" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_TZ3tQh6tzPI/SjORvZwSPAI/AAAAAAAAAHA/F35_Zi55OEE/s72-c/Screenshot+2009.06.13+13.34.54.png" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUQBQXY8cCp7ImA9WxJXGEQ.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-8978585977016284185</id><published>2009-06-11T14:16:00.000-07:00</published><updated>2009-06-13T04:42:30.878-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-13T04:42:30.878-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="IPhone" /><category scheme="http://www.blogger.com/atom/ns#" term="memory" /><title>Iphone and memory management</title><content type="html">Ok, 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).&lt;div&gt;So this means that your application, usually can't take more than 50 to 60 Mb of RAM.&lt;/div&gt;&lt;div&gt;For myselfs I've put some guidelines to manage that limitation :&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. Never use more memory than needed for the view you are in, so release, release&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2. Every viewcontroller should be released as soon it's pushed in a navigation controller&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3. Use proxy's (lazy object creation)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;4. use SQLite for caching (store your objects in a SQLLite database, this database is not using   RAM)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;5. Prepare your application for the worsed and implement the didRecieveMemoryWarning method&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-8978585977016284185?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/8978585977016284185/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/06/iphone-and-memory-management.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/8978585977016284185?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/8978585977016284185?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/06/iphone-and-memory-management.html" title="Iphone and memory management" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;A0cBQHc7cCp7ImA9WxJQE0s.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-9090803360875847291</id><published>2009-05-24T00:24:00.000-07:00</published><updated>2009-05-26T13:17:31.908-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-26T13:17:31.908-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="stock market" /><category scheme="http://www.blogger.com/atom/ns#" term="technical analysis" /><category scheme="http://www.blogger.com/atom/ns#" term="sell" /><category scheme="http://www.blogger.com/atom/ns#" term="trading" /><category scheme="http://www.blogger.com/atom/ns#" term="buy" /><category scheme="http://www.blogger.com/atom/ns#" term="isignals" /><category scheme="http://www.blogger.com/atom/ns#" term="IPhone" /><category scheme="http://www.blogger.com/atom/ns#" term="financial application" /><title>Iphone &amp; Cocoa Touch : the final frontier</title><content type="html">I'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.&lt;div&gt;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).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now to get an idea how the application will lookalike I post here some screenshots. &lt;/div&gt;&lt;div&gt;(ps: the website where you can find some more info is &lt;a href="http://www.isignals.biz/"&gt;www.isignals.biz&lt;/a&gt; ).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The iPhone app will be released in a month or so (maybe after holiday season, so I have sometime to do beta testing).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img style="cursor:pointer; cursor:hand;width: 168px; height: 320px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/Shj3uKpqJHI/AAAAAAAAAGo/EdFjuh04nL8/s320/Afbeelding+1.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339289730752849010" /&gt;&lt;img style="cursor:pointer; cursor:hand;width: 169px; height: 320px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/Shj3-vMon7I/AAAAAAAAAG4/MetO5be1Pzw/s320/Afbeelding+4.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339290015441133490" /&gt;&lt;img style="cursor:pointer; cursor:hand;width: 170px; height: 320px;" src="http://3.bp.blogspot.com/_TZ3tQh6tzPI/Shj359uxtsI/AAAAAAAAAGw/L5tfewO4YXs/s320/Afbeelding+3.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339289933443086018" /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-9090803360875847291?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/9090803360875847291/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/05/bit-off-line-lately.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/9090803360875847291?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/9090803360875847291?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/05/bit-off-line-lately.html" title="Iphone &amp; Cocoa Touch : the final frontier" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_TZ3tQh6tzPI/Shj3uKpqJHI/AAAAAAAAAGo/EdFjuh04nL8/s72-c/Afbeelding+1.jpg" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C0AGRnYyfSp7ImA9WxJTFE4.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-9220300944805967321</id><published>2009-04-22T13:16:00.000-07:00</published><updated>2009-04-22T13:22:07.895-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-22T13:22:07.895-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="date formatter" /><category scheme="http://www.blogger.com/atom/ns#" term="NSDateFormatter" /><title>NSDateFormatter in OSX 10.4.11</title><content type="html">Today I found some strange behaviour in the NSDateFormatter :&lt;br /&gt;If I execute the following code :&lt;br /&gt;&lt;br /&gt;    NSDateFormatter *timeFormatter = [[[NSDateFormatter alloc] init] autorelease];&lt;br /&gt;    [timeFormatter setDateStyle:NSDateFormatterNoStyle];&lt;br /&gt;    [timeFormatter setTimeStyle:NSDateFormatterMediumStyle];&lt;br /&gt;    NSDate *stringTime = [NSDate date];&lt;br /&gt;    NSString *formattedDateStringTime = [timeFormatter stringFromDate:stringTime];&lt;br /&gt;    [theTime setStringValue: formattedDateStringTime] ;&lt;br /&gt;&lt;br /&gt;Then , instead of displaying the time, it shows me the date.&lt;br /&gt;&lt;br /&gt;If I add the following line on top :&lt;br /&gt;&lt;br /&gt;[NSDateFormatter setDefaultFormatterBehavior: NSDateFormatterBehavior10_4] ;&lt;br /&gt;&lt;br /&gt;It gives me correctly the time.&lt;br /&gt;&lt;br /&gt;is this something specific for the 10.4.11 ? Is this behavior also observed in the 10.5.X ?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-9220300944805967321?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/9220300944805967321/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/04/nsdateformatter-in-osx-10411.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/9220300944805967321?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/9220300944805967321?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/04/nsdateformatter-in-osx-10411.html" title="NSDateFormatter in OSX 10.4.11" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;A04MSXw8eyp7ImA9WxJTEU4.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-7154343968373379126</id><published>2009-04-18T23:52:00.000-07:00</published><updated>2009-04-19T04:19:48.273-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-19T04:19:48.273-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="dock icon" /><category scheme="http://www.blogger.com/atom/ns#" term="application badge" /><title>Application badge in Dock</title><content type="html">In Leopard (OSX v10.5 and higher) you have the capability to set an application badge like you can find on iMail for example :&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_TZ3tQh6tzPI/SerKk2kstvI/AAAAAAAAAEQ/FvBcBlnjHxk/s1600-h/Afbeelding+1.png"&gt;&lt;img style="cursor: pointer; width: 62px; height: 62px;" src="http://4.bp.blogspot.com/_TZ3tQh6tzPI/SerKk2kstvI/AAAAAAAAAEQ/FvBcBlnjHxk/s320/Afbeelding+1.png" alt="" id="BLOGGER_PHOTO_ID_5326292243792574194" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;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 &lt;a href="http://www.cocoadev.com/index.pl?DockIconCounter"&gt;CocoaDev&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;This utility class does not only gives the capability to draw the badge gives also the possibility to change the position of the badge :&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SesGtR2_WrI/AAAAAAAAAEw/FPwvw9gZAJI/s1600-h/Afbeelding+5.png"&gt;&lt;img style="cursor: pointer; width: 81px; height: 66px;" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SesGtR2_WrI/AAAAAAAAAEw/FPwvw9gZAJI/s320/Afbeelding+5.png" alt="" id="BLOGGER_PHOTO_ID_5326358359253670578" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_TZ3tQh6tzPI/SesGtTW0kiI/AAAAAAAAAE4/sDDx5hXEVHE/s1600-h/Afbeelding+6.png"&gt;&lt;img style="cursor: pointer; width: 76px; height: 67px;" src="http://3.bp.blogspot.com/_TZ3tQh6tzPI/SesGtTW0kiI/AAAAAAAAAE4/sDDx5hXEVHE/s320/Afbeelding+6.png" alt="" id="BLOGGER_PHOTO_ID_5326358359655617058" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_TZ3tQh6tzPI/SesGtVNYd3I/AAAAAAAAAEo/qrqb9iZSMzQ/s1600-h/Afbeelding+4.png"&gt;&lt;img style="cursor: pointer; width: 74px; height: 67px;" src="http://3.bp.blogspot.com/_TZ3tQh6tzPI/SesGtVNYd3I/AAAAAAAAAEo/qrqb9iZSMzQ/s320/Afbeelding+4.png" alt="" id="BLOGGER_PHOTO_ID_5326358360152897394" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_TZ3tQh6tzPI/SesGtNNqbWI/AAAAAAAAAEg/igspUVmAdQc/s1600-h/Afbeelding+3.png"&gt;&lt;img style="cursor: pointer; width: 77px; height: 68px;" src="http://4.bp.blogspot.com/_TZ3tQh6tzPI/SesGtNNqbWI/AAAAAAAAAEg/igspUVmAdQc/s320/Afbeelding+3.png" alt="" id="BLOGGER_PHOTO_ID_5326358358006590818" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_TZ3tQh6tzPI/SesGtH9d9UI/AAAAAAAAAEY/7AWV_txw5Mk/s1600-h/Afbeelding+2.png"&gt;&lt;img style="cursor: pointer; width: 75px; height: 65px;" src="http://3.bp.blogspot.com/_TZ3tQh6tzPI/SesGtH9d9UI/AAAAAAAAAEY/7AWV_txw5Mk/s320/Afbeelding+2.png" alt="" id="BLOGGER_PHOTO_ID_5326358356596487490" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Changing the font size of the badge:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_TZ3tQh6tzPI/SesHr7aUzvI/AAAAAAAAAFg/FpYxxFhdfM4/s1600-h/Afbeelding+7.png"&gt;&lt;img style="cursor: pointer; width: 77px; height: 71px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/SesHr7aUzvI/AAAAAAAAAFg/FpYxxFhdfM4/s320/Afbeelding+7.png" alt="" id="BLOGGER_PHOTO_ID_5326359435559620338" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_TZ3tQh6tzPI/SesHsJ1Tn9I/AAAAAAAAAFo/-praZo50OQA/s1600-h/Afbeelding+8.png"&gt;&lt;img style="cursor: pointer; width: 77px; height: 70px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/SesHsJ1Tn9I/AAAAAAAAAFo/-praZo50OQA/s320/Afbeelding+8.png" alt="" id="BLOGGER_PHOTO_ID_5326359439430885330" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_TZ3tQh6tzPI/SesHsO9i-wI/AAAAAAAAAFw/F_JKK5qB2m4/s1600-h/Afbeelding+9.png"&gt;&lt;img style="cursor: pointer; width: 78px; height: 70px;" src="http://4.bp.blogspot.com/_TZ3tQh6tzPI/SesHsO9i-wI/AAAAAAAAAFw/F_JKK5qB2m4/s320/Afbeelding+9.png" alt="" id="BLOGGER_PHOTO_ID_5326359440807623426" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_TZ3tQh6tzPI/SesHsXKwR5I/AAAAAAAAAF4/tnV_ruyDFq4/s1600-h/Afbeelding+10.png"&gt;&lt;img style="cursor: pointer; width: 76px; height: 70px;" src="http://3.bp.blogspot.com/_TZ3tQh6tzPI/SesHsXKwR5I/AAAAAAAAAF4/tnV_ruyDFq4/s320/Afbeelding+10.png" alt="" id="BLOGGER_PHOTO_ID_5326359443010504594" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Changing the color of the badge:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_TZ3tQh6tzPI/SesIWAC2D0I/AAAAAAAAAGQ/mUQz85OXEp0/s1600-h/Afbeelding+13.png"&gt;&lt;img style="cursor: pointer; width: 75px; height: 69px;" src="http://4.bp.blogspot.com/_TZ3tQh6tzPI/SesIWAC2D0I/AAAAAAAAAGQ/mUQz85OXEp0/s320/Afbeelding+13.png" alt="" id="BLOGGER_PHOTO_ID_5326360158357819202" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SesIWAPM5PI/AAAAAAAAAGI/XoL9-rtV-fQ/s1600-h/Afbeelding+12.png"&gt;&lt;img style="cursor: pointer; width: 77px; height: 73px;" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SesIWAPM5PI/AAAAAAAAAGI/XoL9-rtV-fQ/s320/Afbeelding+12.png" alt="" id="BLOGGER_PHOTO_ID_5326360158409647346" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_TZ3tQh6tzPI/SesIVwswajI/AAAAAAAAAGA/LSC_7eySZF4/s1600-h/Afbeelding+11.png"&gt;&lt;img style="cursor: pointer; width: 78px; height: 72px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/SesIVwswajI/AAAAAAAAAGA/LSC_7eySZF4/s320/Afbeelding+11.png" alt="" id="BLOGGER_PHOTO_ID_5326360154238642738" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The code can be downloaded &lt;a href="http://www.box.net/shared/gzc2hde0lq"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-7154343968373379126?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/7154343968373379126/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/04/application-badge-in-dock.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/7154343968373379126?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/7154343968373379126?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/04/application-badge-in-dock.html" title="Application badge in Dock" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_TZ3tQh6tzPI/SerKk2kstvI/AAAAAAAAAEQ/FvBcBlnjHxk/s72-c/Afbeelding+1.png" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkANSHY5eip7ImA9WxVaGUg.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-38430330930261395</id><published>2009-04-16T23:43:00.000-07:00</published><updated>2009-04-16T23:46:39.822-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-16T23:46:39.822-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="examples" /><category scheme="http://www.blogger.com/atom/ns#" term="NSNumberFormatter" /><title>NSNumberformatter: some examples</title><content type="html">I was looking for some examples on the usage of the NSNumberformatter class. During this search I stumbled on the &lt;a href="http://samuellam.wordpress.com/"&gt;weblog of Sam Lam&lt;/a&gt; which provides some good examples.&lt;br /&gt;&lt;br /&gt;I copy them here , as I use my own blog as a sort of FAQ or HOW-TO for myself.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;-(NSString*) formatCurrencyValue:(double)value&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  [numberFormatter setCurrencySymbol:@"$"];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  NSNumber *c = [NSNumber numberWithFloat:value];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  return [numberFormatter stringFromNumber:c];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;-(NSString*) formatPercentValue:(double)value&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  [numberFormatter setPercentSymbol:@"%"];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  [numberFormatter setNumberStyle: NSNumberFormatterPercentStyle];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  [numberFormatter setDecimalSeparator:@"."];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  [numberFormatter setGeneratesDecimalNumbers:TRUE];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  [numberFormatter setMinimumFractionDigits:2];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  [numberFormatter setRoundingMode: NSNumberFormatterRoundUp];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  [numberFormatter setRoundingIncrement:[[NSNumber alloc]initWithDouble:0.05]];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  NSNumber *c = [NSNumber numberWithFloat:value];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  return [numberFormatter stringFromNumber:c];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;-(double) formatDoubleFromCurrency:(NSString*)value&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  double ret ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  if(value)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    ret = [value doubleValue];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    if (ret == 0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;     {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;      NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;      [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;      [numberFormatter setCurrencySymbol:@"$"];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;      [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;      NSNumber *c = [numberFormatter numberFromString:value];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;      ret = [c doubleValue];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;     }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;     return ret;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    return 0.0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-38430330930261395?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/38430330930261395/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/04/nsnumberformatter-some-examples.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/38430330930261395?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/38430330930261395?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/04/nsnumberformatter-some-examples.html" title="NSNumberformatter: some examples" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C04BQnc-fip7ImA9WxVaGUw.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-5997966542623599809</id><published>2009-04-16T12:55:00.000-07:00</published><updated>2009-04-16T12:59:13.956-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-16T12:59:13.956-07:00</app:edited><title>NSButton: setting an image in a button</title><content type="html">I always have trouble to know how to set an image in a button. The following code snippet does the job:&lt;br /&gt;&lt;br /&gt;    NSString* im1 = [[NSBundle mainBundle] pathForResource:@"arrow right" ofType:@"png"];&lt;br /&gt;    NSURL* url2 = [NSURL fileURLWithPath:im1];&lt;br /&gt;    NSImage *image =  [[NSImage alloc] initWithContentsOfURL: url2];&lt;br /&gt;   &lt;br /&gt;   &lt;br /&gt;    [toggleButton setImage: image] ;&lt;br /&gt;   &lt;br /&gt;    NSString *im2 = [[NSBundle mainBundle] pathForResource:@"arrow left" ofType:@"png"];&lt;br /&gt;    url2 = [NSURL fileURLWithPath:im2];&lt;br /&gt;    image =  [[NSImage alloc] initWithContentsOfURL: url2];&lt;br /&gt;    [toggleButton setAlternateImage: image] ;&lt;br /&gt;&lt;br /&gt;The code above set's 2 images in  a toggle button .&lt;br /&gt;&lt;br /&gt;Note that if you want transparant images , you need .png files and not jpeg's (GIF also works)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-5997966542623599809?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/5997966542623599809/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/04/nsbutton-setting-image-in-button.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/5997966542623599809?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/5997966542623599809?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/04/nsbutton-setting-image-in-button.html" title="NSButton: setting an image in a button" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkIBQ3g6fyp7ImA9Wx9WFEg.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-205266527662271641</id><published>2009-04-16T06:23:00.000-07:00</published><updated>2011-01-19T09:35:52.617-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-19T09:35:52.617-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="telemeter" /><category scheme="http://www.blogger.com/atom/ns#" term="mac osx" /><category scheme="http://www.blogger.com/atom/ns#" term="telenet" /><title>For telenet users: a telemeter application</title><content type="html">&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#CC0000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#CC0000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#CC0000;"&gt;Note: the application is updated ! It's now compatible with the new Telemeter service of Telenet (new version since July 2010)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#CC0000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#CC0000;"&gt;Also available for the iPhone see following &lt;a href="http://mac-objective-c.blogspot.com/2010/08/telenet-telemeter-for-iphoneipod.html"&gt;blog message&lt;/a&gt; .&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#CC0000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;This little &lt;a href="http://www.box.net/shared/2ksfgds4r6"&gt;application&lt;/a&gt; shows how much data you've downloaded/uploaded from your Telenet account.&lt;div&gt;(for the impatients : you can find the dmg &lt;a href="http://www.box.net/shared/2ksfgds4r6"&gt;here&lt;/a&gt; ) .&lt;br /&gt;&lt;br /&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 254px;" src="http://3.bp.blogspot.com/_TZ3tQh6tzPI/TEgtAaIH95I/AAAAAAAAAI8/Tw6XZyGrm-s/s320/Schermafbeelding+2010-07-22+om+13.29.28.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5496692830242338706" /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For those with an unlimited download (turbonet, fibernet) the screen will look like follows :&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 256px;" src="http://3.bp.blogspot.com/_TZ3tQh6tzPI/TFPxzNeNWyI/AAAAAAAAAJE/dKt3hLR-H6s/s320/Schermafbeelding+2010-07-31+om+11.39.49.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5500005432041495330" /&gt;&lt;br /&gt;&lt;br /&gt;Installation is very easy :&lt;br /&gt;&lt;br /&gt;1. Open the dmg file (&lt;a href="http://www.box.net/shared/2ksfgds4r6"&gt;download here&lt;/a&gt;) ;&lt;br /&gt;2. drag and drop the folder 'Telemeter' wherever you want ;&lt;br /&gt;3. Start the Telemeter v2 application.&lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;In the screen you see also a button with an arrow (&gt;) , if you click that you'll get the daily usage details.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_TZ3tQh6tzPI/SfMaCSz-yJI/AAAAAAAAAGg/IhNrWFAUx3g/s1600-h/Afbeelding+2.png"&gt;&lt;img style="cursor: pointer; width: 320px; height: 145px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/SfMaCSz-yJI/AAAAAAAAAGg/IhNrWFAUx3g/s320/Afbeelding+2.png" alt="" id="BLOGGER_PHOTO_ID_5328631410821351570" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The application will update the data from Telenet every 30 minutes.&lt;br /&gt;&lt;br /&gt;&lt;enter&gt;&lt;br /&gt;&lt;/enter&gt;&lt;br /&gt;&lt;enter&gt;Next enhancements :&lt;br /&gt;&lt;/enter&gt;&lt;br /&gt;&lt;enter&gt;1. Make a dashboard widget of it&lt;br /&gt;2. Change the icon colour depending on the used bandwidth&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Note: this is a first version , so please report any bugs to me (via blog or email). Comments are also welcome of course.&lt;br /&gt;&lt;/enter&gt;&lt;br /&gt;&lt;enter&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;UPDATE&lt;/span&gt;&lt;/span&gt; :&lt;br /&gt;&lt;/enter&gt;&lt;br /&gt;&lt;enter&gt;I made the following enhancements :&lt;br /&gt;&lt;br /&gt;1. you see in the tray bar (system menu bar) the percentage used :&lt;br /&gt;&lt;br /&gt;&lt;/enter&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_TZ3tQh6tzPI/Seine1cB-gI/AAAAAAAAADo/jubiUNh48HA/s1600-h/Afbeelding+2.png"&gt;&lt;img style="cursor: pointer; width: 320px; height: 18px;" src="http://3.bp.blogspot.com/_TZ3tQh6tzPI/Seine1cB-gI/AAAAAAAAADo/jubiUNh48HA/s320/Afbeelding+2.png" alt="" id="BLOGGER_PHOTO_ID_5325690707548174850" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;2. In the dock , the icon will also show the percentage used&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_TZ3tQh6tzPI/SeinzAzuOzI/AAAAAAAAADw/gBz_1OGH2HM/s1600-h/Afbeelding+1.png"&gt;&lt;img style="cursor: pointer; width: 320px; height: 49px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/SeinzAzuOzI/AAAAAAAAADw/gBz_1OGH2HM/s320/Afbeelding+1.png" alt="" id="BLOGGER_PHOTO_ID_5325691054197717810" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;3. several small bugfixes&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;UPDATE&lt;/span&gt; &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;2&lt;/span&gt;: just found out that I have some memory leaks, will solve them ASAP.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;UPDATE&lt;/span&gt; &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;3&lt;/span&gt; : memory leaks solved + some minor improvements&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;UPDATE&lt;/span&gt; &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;4&lt;/span&gt; : major enhancements&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;UPDATE 5&lt;/span&gt; : Currently (5 May) telemeter service is down&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;UPDATE 6&lt;/span&gt;: We are 7th of May and the telemeter service is still down. And this in Internet age....&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;UPDATE 7&lt;/span&gt;: And now they've changed the protocol.... pff they really annoy me. I changed the XML processing , so it works again&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;UPDATE 8&lt;/b&gt;: Application rewritten because Telenet has changed completely the webservice&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-205266527662271641?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/205266527662271641/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/04/for-telenet-users-telemeter-application.html#comment-form" title="10 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/205266527662271641?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/205266527662271641?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/04/for-telenet-users-telemeter-application.html" title="For telenet users: a telemeter application" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_TZ3tQh6tzPI/TEgtAaIH95I/AAAAAAAAAI8/Tw6XZyGrm-s/s72-c/Schermafbeelding+2010-07-22+om+13.29.28.png" height="72" width="72" /><thr:total>10</thr:total></entry><entry gd:etag="W/&quot;DEcNQ386eSp7ImA9WxVaFkQ.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-6119187272154949045</id><published>2009-04-14T00:40:00.000-07:00</published><updated>2009-04-14T01:01:32.111-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-14T01:01:32.111-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="drawing in views" /><category scheme="http://www.blogger.com/atom/ns#" term="exploded arc" /><category scheme="http://www.blogger.com/atom/ns#" term="views" /><category scheme="http://www.blogger.com/atom/ns#" term="drawing" /><category scheme="http://www.blogger.com/atom/ns#" term="slice" /><category scheme="http://www.blogger.com/atom/ns#" term="pie chart" /><title>Drawing pie charts</title><content type="html">Recently I was looking for a way to draw pie charts (you know, the one with an 'exploded' slice) on my Macbook.&lt;br /&gt;Unfortunealy I didn't find much on the Internet, so I've started to experiment a bit myselfs.&lt;br /&gt;The following code draws a pie chart with one slice exploded from the other :&lt;br /&gt;&lt;br /&gt;The trick is that you draw an imaginary circle around the center, on this circle is the center of the 'exploded' slice.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;#define PI 3.14159265358979323846&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;   NSBezierPath *greenPath = [NSBezierPath bezierPath] ;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;// set some line width&lt;br /&gt;&lt;br /&gt; &lt;span style="font-family:courier new;"&gt;[greenPath setLineWidth: 2 ] ;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;// move to the center so that we have a closed slice&lt;br /&gt; // size_x and size_y are the height and width of the view&lt;br /&gt;&lt;br /&gt;[greenPath moveToPoint: NSMakePoint( size_x/2, size_y/2 ) ] ;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;// draw an arc (perc is a certain percentage ; something between 0 and 1&lt;br /&gt; &lt;span style="font-family:courier new;"&gt;[greenPath appendBezierPathWithArcWithCenter:NSMakePoint( size_x/2, size_y/2) radius:50 startAngle:0 endAngle: 360 * perc  ] ;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;// close the slice , by drawing a line to the center&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[greenPath lineToPoint: NSMakePoint(size_x/2, size_y/2) ] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    [greenPath stroke] ;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    [[NSColor greenColor] set] ;&lt;br /&gt;&lt;/span&gt;// and fill it&lt;br /&gt; &lt;span style="font-family:courier new;"&gt;[greenPath fill] ;&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;    &lt;/span&gt; &lt;span style="font-family:courier new;"&gt;   &lt;br /&gt;&lt;br /&gt;greenPath = [NSBezierPath bezierPath] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    [[NSColor blackColor] set] ;&lt;/span&gt;&lt;br /&gt; &lt;span style="font-family:courier new;"&gt;[greenPath setLineWidth: 2 ] ;&lt;br /&gt;&lt;br /&gt;// draw the second slice, now exploded from the original center&lt;br /&gt;&lt;br /&gt;// so to get it exploded I move (10,7) points from the original center&lt;br /&gt;// but on the imaginary circle (thats why the cos and the sin)&lt;br /&gt;// note mide_angle is the angle halve way from the arc, you can experiment with multiple&lt;br /&gt;// angles, note also that the angle is in degrees&lt;br /&gt;&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;[greenPath moveToPoint: NSMakePoint(size_x/2 - 10 * cos ( PI * mid_angle / &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;180 ) , size_y/2 - 7 * sin ( PI * mid_angle / 180 )) ] ;&lt;br /&gt;&lt;br /&gt;// and now draw the other slice&lt;br /&gt;&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;[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  ] ;&lt;br /&gt;&lt;br /&gt;// close the slice&lt;br /&gt;&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;[greenPath lineToPoint: NSMakePoint( size_x/2 - 10 * cos ( PI * mid_angle / 180 ) , size_y/2 - 7 * sin ( PI * mid_angle / 180 ) ) ] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    [greenPath stroke] ;&lt;br /&gt;&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;[[NSColor blueColor] set] ;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt; &lt;span style="font-family:courier new;"&gt;[greenPath fill] ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The result of above code is here :&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SeRAuteJ4GI/AAAAAAAAADQ/6VRQq3Tbcks/s1600-h/Afbeelding+1.png"&gt;&lt;img style="cursor: pointer; width: 122px; height: 118px;" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SeRAuteJ4GI/AAAAAAAAADQ/6VRQq3Tbcks/s320/Afbeelding+1.png" alt="" id="BLOGGER_PHOTO_ID_5324451830683000930" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Next time I'll add some code to add text to the slices&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-6119187272154949045?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/6119187272154949045/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/04/drawing-pie-charts.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/6119187272154949045?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/6119187272154949045?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/04/drawing-pie-charts.html" title="Drawing pie charts" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SeRAuteJ4GI/AAAAAAAAADQ/6VRQq3Tbcks/s72-c/Afbeelding+1.png" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkMEQXk_eCp7ImA9WxVaEUo.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-8102238895963369516</id><published>2009-04-07T23:26:00.000-07:00</published><updated>2009-04-08T00:06:40.740-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-08T00:06:40.740-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Webservices" /><category scheme="http://www.blogger.com/atom/ns#" term="SOAP" /><category scheme="http://www.blogger.com/atom/ns#" term="XML" /><category scheme="http://www.blogger.com/atom/ns#" term="Cocoa" /><category scheme="http://www.blogger.com/atom/ns#" term="WSDL" /><title>SOAP: webservices in Objective-C/Cocoa</title><content type="html">Lately 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.&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;So I decided to build a Dashboard widget (in Objective-C, not in Javascript) to see the statistics from my desktop.&lt;br /&gt;&lt;br /&gt;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).&lt;br /&gt;So I  did some experimentation with the samples from Apple itself :&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt; &lt;span style="font-size:78%;"&gt;   // SOAP request settings&lt;br /&gt;&lt;br /&gt;    NSURL *url = [NSURL URLWithString:@"https://telemeter4tools.services.telenet.be/TelemeterService"];&lt;br /&gt;&lt;br /&gt;    // the name of the webservice&lt;br /&gt;    NSString *method = @"getUsage";&lt;br /&gt;&lt;br /&gt;    // the namespace&lt;br /&gt;    NSString *namespace = @"https://telemeter4tools.services.telenet.be/";&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    // SOAP request params&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;br /&gt;    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"**username**",&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        @"string",&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        @"**password**",&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        @"string0",&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        nil];&lt;br /&gt;&lt;br /&gt;    // the parameters itself are in a dictionary, a dictionary is an unordered collection&lt;br /&gt;    // so to define the order in which the parameters must be sent&lt;br /&gt;    // you need to fill an array with the NAMES of the parameters&lt;br /&gt;&lt;br /&gt;    NSArray *paramOrder = [NSArray arrayWithObjects:@"string", @"string0"];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;br /&gt;    // set SOAP request http headers -- some SOAP server impls require even empty SOAPAction headers&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;br /&gt;&lt;br /&gt;    NSDictionary *reqHeaders = [NSDictionary dictionaryWithObject:@"" forKey:@"SOAPAction"];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;br /&gt;    // create SOAP request&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;br /&gt;    WSMethodInvocationRef soapReq = createsoapReq(url, method, namespace, params, paramOrder, reqHeaders);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;br /&gt;    // invoke SOAP request&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;br /&gt;    NSDictionary *result = (NSDictionary *)WSMethodInvocationInvoke(soapReq);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;br /&gt;    // get HTTP response from SOAP request so we can see response HTTP status code&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;br /&gt;    CFHTTPMessageRef res = (CFHTTPMessageRef)[result objectForKey:(id)kWSHTTPResponseMessage];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;   &lt;br /&gt; The response of a SOAP requests is a dictionary, and it looks like this :&lt;br /&gt;&lt;br /&gt;result: {&lt;br /&gt;    "/Result" = { ... &lt;&lt;&gt;&gt; };&lt;br /&gt;&lt;br /&gt;    "/WSDebugInBody" = "&lt;?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?&gt;&lt;env:envelope env="\" xsi="\" soapenc="\" xsd="\"&gt;&lt;env:body encodingstyle="\"&gt;&lt;m:getusageresponse m="\"&gt;...etc;&lt;br /&gt;&lt;br /&gt;    "/WSDebugInHeaders" = {&lt;br /&gt;        "Accept-Ranges" = none;&lt;br /&gt;        Connection = close;&lt;br /&gt;        "Content-Length" = 4840;&lt;br /&gt;        "Content-Type" = "text/xml; charset=utf-8";&lt;br /&gt;        Date = "Wed, 08 Apr 2009 06:44:46 GMT";&lt;br /&gt;        "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=/";&lt;br /&gt;    };&lt;br /&gt;    "/WSDebugOutBody" = &lt;&lt;&gt;&gt;";&lt;br /&gt;    "/WSDebugOutHeaders" = {&lt;br /&gt;        "Content-Type" = "text/xml";&lt;br /&gt;        Host = "telemeter4tools.services.telenet.be";&lt;br /&gt;        Soapaction = "";&lt;br /&gt;        "User-Agent" = "Mac OS X; WebServicesCore.framework (1.1.0)";&lt;br /&gt;    };&lt;br /&gt;    "/kWSHTTPResponseMessage" = &lt;&lt;&gt;&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Note that I stripped a bit the contents of the dictionary.&lt;br /&gt;&lt;br /&gt;Now to get the result of the webservice you must get the proper data from the dictionary (in this case this is  &lt;span style="font-family: courier new;"&gt;data = [result objectForKey: @"result"]&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;This will return a string value, so a next step is to create an XMLDocument of it :&lt;br /&gt;&lt;br /&gt;         &lt;span style="font-family: courier new;"&gt;NSXMLDocument *document ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    NSError *error ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    NSXMLNode *node ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    document = (NSXMLDocument *) [NSXMLDocument document] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [document initWithXMLString: data options: NSXMLDocumentTidyXML error: &amp;amp;error ] &lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;And once it is in a XMLDocument , you can use XPath expressions to query the document :&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;myArray = [document objectsForXQuery: @"/ns1:telemeter[1]/ns1:usage-info[1]/ns1:data[1]/@timestamp"   error: &amp;amp;error ] ;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now this looks to me a very complex process  to get something from a webservice.&lt;br /&gt;I'm now looking at WSDL and the utility WSMakeStubs to see if I can simplify this.&lt;br /&gt;The nicest thing would be that we have something like JAXB to 'objectify' webservice responses&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-8102238895963369516?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/8102238895963369516/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/04/soap-webservices-in-objective-ccocoa.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/8102238895963369516?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/8102238895963369516?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/04/soap-webservices-in-objective-ccocoa.html" title="SOAP: webservices in Objective-C/Cocoa" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CU8DR3w_cSp7ImA9WxVbFEk.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-6206524686796894631</id><published>2009-03-29T23:19:00.000-07:00</published><updated>2009-03-30T13:11:16.249-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-30T13:11:16.249-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="pimm" /><category scheme="http://www.blogger.com/atom/ns#" term="depth first search" /><category scheme="http://www.blogger.com/atom/ns#" term="maze generation" /><category scheme="http://www.blogger.com/atom/ns#" term="Maze" /><title>Generating mazes</title><content type="html">In an attempt to create a video game, I came across the problem of creating a maze (see figure).&lt;div&gt;&lt;img style="cursor: pointer; width: 318px; height: 320px;" src="http://3.bp.blogspot.com/_TZ3tQh6tzPI/SdBlPw41eoI/AAAAAAAAADI/Co1SxHQ3DqM/s320/Afbeelding+1.png" alt="" id="BLOGGER_PHOTO_ID_5318862481420286594" border="0" /&gt;&lt;br /&gt;&lt;div&gt;Like in most games you need to go from point A to point B via a number of corridors.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now my problem was to find a good algorithm to create mazes, and after some research on the Internet I found several of them (see &lt;a href="http://en.wikipedia.org/wiki/Maze_generation_algorithm"&gt;wikipedia&lt;/a&gt; for an explanantion) .&lt;/div&gt;&lt;div&gt;My first attempt was to use the simpelst algorithm , being the &lt;span style="font-style: italic;"&gt;Depth-first search&lt;/span&gt; algorithm.&lt;/div&gt;&lt;div&gt;The algorithm goes as follows :&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;1, Initialize a grid full of walls&lt;br /&gt;2, Start at a particular cell and call it the "exit."&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;3, Mark the current cell as visited, and get a list of its neighbors. For each neighbor, starting with a randomly selected neighbor:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;          If that neighbor hasn't been visited, remove the wall between this cell and that neighbor, and  then recurse with that neighbor as the current cell.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;So to implement this , I'll developed a recursive method (uses more memory and in a later state I can use a stack to avoid recursion).&lt;br /&gt;&lt;br /&gt;In objective-C the implementation looks like this (very premature source code of the maze creation program (with animated GUI) can be downloaded &lt;a href="http://www.box.net/shared/c74ged7m1d"&gt;here&lt;/a&gt;) :&lt;br /&gt;&lt;br /&gt;step 1 : Initialize a grid&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;for ( x = 0 ; x &lt;&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        for ( y = 0 ; y &lt;&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            cell = [MazeCell fullCell] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            [cell x: x ] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            [cell y: y] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            [maze atX: x atY: y put: cell]           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A MazeCell is an object that contains four 'wall's' (a wall is here a BOOL that is true or false dending on the fact if the wall is their or not.&lt;br /&gt;&lt;br /&gt;Step 2 : the actual generation of the maze&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;- (void) walkCells: (MazeCell *) aCell&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    int x ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    int y ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    NSMutableSet *neighbors ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    MazeCell *cell1 ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    NSEnumerator *enumerator ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    [aCell visited: YES] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    x = [aCell x];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    y = [aCell y];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    neighbors = [NSMutableSet set] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    if ( x &gt; 0 ) [neighbors addObject: [maze atX: (x-1) atY: y ]] ;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    if ( y &gt; 0 )  [neighbors addObject: [maze atX: (x) atY: (y-1) ]] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    if ( x &lt;&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    if ( y &lt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    enumerator = [ neighbors objectEnumerator] ;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    while ( (cell1 = [enumerator nextObject] ) != nil )&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        if ( [cell1 visited] == NO )&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            if ( [cell1 x] == (x-1) ) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                [cell1 rightWall: NO] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                [aCell leftWall: NO] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            if ( [cell1 x] == (x+1) ) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                [aCell rightWall: NO] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                [cell1 leftWall: NO] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            if ( [cell1 y] == (y-1) ) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                [cell1 upWall: NO] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                [aCell downWall: NO] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            if ( [cell1 y] == (y+1) ) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                [aCell upWall: NO] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                [cell1 downWall: NO] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            [self walkCells: cell1] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:georgia;font-size:130%;"&gt;&lt;span style="font-family:georgia;"&gt;A little explanation is needed here , in the beginning of the method you see that I build a list of the neighbours of cell.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;Now it is important that the list is build in a random order, so therefor I use a NSMutableSet as datastructure. The position in the set depends on the hash that is generated for the object that is inserted.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;In my case these objects are of type MazeCell.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;So the trick to get them in random order was to implement the hash method on MazeCell and this hash method just returns a random number.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-6206524686796894631?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/6206524686796894631/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/03/generating-mazes.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/6206524686796894631?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/6206524686796894631?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/03/generating-mazes.html" title="Generating mazes" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_TZ3tQh6tzPI/SdBlPw41eoI/AAAAAAAAADI/Co1SxHQ3DqM/s72-c/Afbeelding+1.png" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C04ARHg4fip7ImA9WxVUF0Q.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-4318758866056038297</id><published>2009-03-22T23:52:00.000-07:00</published><updated>2009-03-23T00:05:45.636-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-23T00:05:45.636-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="texture" /><category scheme="http://www.blogger.com/atom/ns#" term="background" /><category scheme="http://www.blogger.com/atom/ns#" term="drawing" /><category scheme="http://www.blogger.com/atom/ns#" term="NSImage" /><title>Drawing in views : background in custom views</title><content type="html">Sometimes it could be usefull to have a background image in view instead of a color. For example if we want to have a texture in a view.&lt;br /&gt;&lt;br /&gt;In the following example I draw a 'wall' as the background of a view :&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_TZ3tQh6tzPI/ScczRf9SBxI/AAAAAAAAAC4/zvDUI_cpYLQ/s1600-h/Afbeelding+1.png"&gt;&lt;img style="cursor: pointer; width: 160px; height: 320px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/ScczRf9SBxI/AAAAAAAAAC4/zvDUI_cpYLQ/s320/Afbeelding+1.png" alt="" id="BLOGGER_PHOTO_ID_5316274260863485714" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The texture I want to apply to my view is the following :&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_TZ3tQh6tzPI/ScczjjfpLCI/AAAAAAAAADA/okgufCZmTAM/s1600-h/wall.jpg"&gt;&lt;img style="cursor: pointer; width: 94px; height: 94px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/ScczjjfpLCI/AAAAAAAAADA/okgufCZmTAM/s320/wall.jpg" alt="" id="BLOGGER_PHOTO_ID_5316274571050560546" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now its very easy to define this as a texture, you just create a new color , and not just a color but a colorpattern :&lt;br /&gt;&lt;br /&gt;Step 1 : find the texture in my resources&lt;br /&gt;&lt;br /&gt;  &lt;span style="font-family: courier new;"&gt;  NSString* fileName = [[NSBundle mainBundle] pathForResource: @"wall" ofType:@"jpg"];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    NSURL* url = [NSURL fileURLWithPath: fileName];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Step 2 : upload the image from the URL &lt;br /&gt; &lt;span style="font-family: courier new;"&gt;   background =  [[NSImage alloc] initWithContentsOfURL: url];&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;Step 3 : define a new color&lt;br /&gt;&lt;br /&gt;    &lt;span style="font-family: courier new;"&gt;color = [NSColor colorWithPatternImage:background ] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [color set] ;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Step 4 : fill the background&lt;br /&gt;   &lt;span style="font-family: courier new;"&gt; NSRectFill( [self bounds] ) ;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note that you need to implement this code also in the drawRect: method, to ensure that each time your view get's redrawn that the background is drawn also.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-4318758866056038297?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/4318758866056038297/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/03/drawing-in-views-background-in-custom.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/4318758866056038297?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/4318758866056038297?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/03/drawing-in-views-background-in-custom.html" title="Drawing in views : background in custom views" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_TZ3tQh6tzPI/ScczRf9SBxI/AAAAAAAAAC4/zvDUI_cpYLQ/s72-c/Afbeelding+1.png" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkEHQ3w_eSp7ImA9WxVUEUQ.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-380229741822083302</id><published>2009-03-16T00:37:00.000-07:00</published><updated>2009-03-16T01:03:52.241-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-16T01:03:52.241-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="core data" /><category scheme="http://www.blogger.com/atom/ns#" term="database" /><category scheme="http://www.blogger.com/atom/ns#" term="saving data" /><title>Saving data to files</title><content type="html">In some circumstances you want to save data to disk, in some cases you will use a database for that. But if you need , for example, to save the highscores of a game then a database will be a bit overkill.&lt;br /&gt;&lt;br /&gt;In that case you can use core data, so lets look at a small example of how this works.&lt;br /&gt;(Consider you already have an application in which you want to include a mechanism to save data).&lt;br /&gt;&lt;br /&gt;Step 1 : add a data model&lt;br /&gt;&lt;br /&gt;In XCode , you open the file assistant (via File&gt;New File) and select 'data model'&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_TZ3tQh6tzPI/Sb4DJ3v6J7I/AAAAAAAAACo/FdeZFdOTeUU/s1600-h/Afbeelding+1.png"&gt;&lt;img style="cursor: pointer; width: 320px; height: 266px;" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/Sb4DJ3v6J7I/AAAAAAAAACo/FdeZFdOTeUU/s320/Afbeelding+1.png" alt="" id="BLOGGER_PHOTO_ID_5313688078462363570" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Once you defined the data model , you'll get something like this :&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_TZ3tQh6tzPI/Sb4D1tZy4xI/AAAAAAAAACw/1W_T4pGhRFk/s1600-h/Afbeelding+2.png"&gt;&lt;img style="cursor: pointer; width: 320px; height: 270px;" src="http://1.bp.blogspot.com/_TZ3tQh6tzPI/Sb4D1tZy4xI/AAAAAAAAACw/1W_T4pGhRFk/s320/Afbeelding+2.png" alt="" id="BLOGGER_PHOTO_ID_5313688831599502098" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I already added an Entity called HighScores , you add the entity via the menuitem (Design&gt;Data Model&gt;Add Entity).&lt;br /&gt;I a same fashion you can add attributes to the entity (Desgin&gt;Data Model&gt;Add Attribute).&lt;br /&gt;In my case I just defined 3 attributes : name,rank and score.&lt;br /&gt;&lt;br /&gt;So this is all their is to define a datamodel (of course this is a very simple datamodel).&lt;br /&gt;Now we need some coding to save information to the datamodel (and to file).&lt;br /&gt;&lt;br /&gt;Step 2 : datastore identification&lt;br /&gt;&lt;br /&gt;First we need to define in which file we will store the information :&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;NSError *error ; // this is for error reporting ; see later&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;NSURL *url = [NSURL fileURLWithPath:@"/Users/Herman/file.xml"];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Step 3 : define the datamodel we will use (= the datamodel in the project)&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt; NSArray *bundles = [NSArray arrayWithObject:[NSBundle mainBundle]];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt; NSManagedObjectModel *model = [NSManagedObjectModel mergedModelFromBundles:bundles];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Step 4 : associate the datamodel  with the datastore (= the file)  via a coordinator&lt;br /&gt;&lt;br /&gt;    NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model];&lt;br /&gt;    [coordinator addPersistentStoreWithType:NSXMLStoreType configuration:nil  URL:url  options: nil error:&amp;amp;error];&lt;br /&gt;   &lt;br /&gt;Step 5 : Get the context&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    context = [[NSManagedObjectContext alloc] init];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [context setPersistentStoreCoordinator: coordinator];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Step 6 : Save some data to the file&lt;br /&gt;&lt;br /&gt;  &lt;span style="font-family: courier new;"&gt;  NSManagedObject *score = [NSEntityDescription insertNewObjectForEntityForName:@"HighScores" inManagedObjectContext:context];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [score setValue:@"bla bla" forKey:@"name"] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [score setValue:[NSNumber numberWithInt: 100] forKey:@"score"] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [score setValue:[NSNumber numberWithInt: 1] forKey:@"rank"] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [context save: &amp;amp;error ] ;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Et voila, we have a simple way of saving data to a file.&lt;br /&gt;In a next message I'll discuss how to retrieve data and do some more complex queries on files.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-380229741822083302?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/380229741822083302/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/03/saving-data-to-files.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/380229741822083302?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/380229741822083302?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/03/saving-data-to-files.html" title="Saving data to files" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_TZ3tQh6tzPI/Sb4DJ3v6J7I/AAAAAAAAACo/FdeZFdOTeUU/s72-c/Afbeelding+1.png" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DE8NSXo-eCp7ImA9WxVVEEs.&quot;"><id>tag:blogger.com,1999:blog-1101980925257123316.post-1818223931548944889</id><published>2009-03-02T23:44:00.000-08:00</published><updated>2009-03-02T23:54:58.450-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-02T23:54:58.450-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rectangles" /><category scheme="http://www.blogger.com/atom/ns#" term="drawing" /><title>Drawing in views: rectangles</title><content type="html">When you want to draw a rectangle (or fill one), you basically have 2 choices :&lt;br /&gt;&lt;br /&gt;1. You want absolute performance and less accuracy then you can use the functions defined in NSGraphics.h (NSFrameRect, NSRectFill etc).&lt;br /&gt;&lt;br /&gt;2. You need absolute accuracy and don't care so much about performance then you can use the methods defined in NSBezierPath.&lt;br /&gt;&lt;br /&gt;(the reason why the NSBezierPath is less performant is explained in this &lt;a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaPerformance/Articles/NSBezierPathTips.html"&gt;article&lt;/a&gt;  ).&lt;br /&gt;&lt;br /&gt;The following code extract is from a drawRect: method of a custom view :&lt;br /&gt;It shows the different methods of drawing and filling a rectangle.&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    NSBezierPath *aPath ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    NSBezierPath *myPath ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    // reset the bounds&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [self setBounds: NSMakeRect(0,0,1000,1000)] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  &lt;span style="color: rgb(51, 255, 51);"&gt;  //---------------------------------&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(51, 255, 51);"&gt;    //1. filling rectangles&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(51, 255, 51);"&gt;    //---------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [[NSColor grayColor] set] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;  &lt;span style="color: rgb(51, 255, 51);"&gt;  // convenience method for filling a rectangle&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(51, 255, 51);"&gt;    // less precise , but good performance&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(51, 255, 51);"&gt;    // C functions defined in NSGraphics.h&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    NSRectFill( rect ) ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;   &lt;span style="color: rgb(51, 255, 51);"&gt; // filling a rectangle using a class method of NSBezierPath&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [NSBezierPath fillRect: NSMakeRect( 0,500,75,75) ] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt; &lt;span style="color: rgb(51, 255, 51);"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;    // filling a rectangle using an instance method of NSBezierPath&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;    // this usefull if you want to do additional drawing in that path&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;    myPath = [NSBezierPath new] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [myPath appendBezierPathWithRect: NSMakeRect ( 600,0,80,80) ] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [myPath fill] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;span style="color: rgb(51, 255, 51);"&gt;// -----------------------------&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(51, 255, 51);"&gt;    //2. drawing a rectangle&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(51, 255, 51);"&gt;    //------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [[NSColor redColor] set ] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;   &lt;span style="color: rgb(51, 255, 51);"&gt; // drawing a rectangle using a class method of NSBezierPath&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [NSBezierPath strokeRect: NSMakeRect( 500,500,80,80 ) ] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;span style="color: rgb(51, 255, 51);"&gt;// drawing a rectangle using an instance method of NSBezierPath&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 255, 51);font-size:85%;" &gt;&lt;span style="font-family: courier new;"&gt;    // this usefull if you want to do additional drawing in that path&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;/span&gt;&lt;span style="font-family: courier new;"&gt;    [[NSColor greenColor] set ] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    aPath = [NSBezierPath  bezierPathWithRect: NSMakeRect( 450,600,100,100) ] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    [aPath stroke] ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;span style="color: rgb(51, 255, 51);"&gt;// absolute performance, less precise&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(51, 255, 51);"&gt;    // C functions defined in NSGraphics.h&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    NSFrameRectWithWidth( NSMakeRect( 700,700,70,70), 10 ) ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    NSFrameRect( NSMakeRect( 0,700,80,80 ) ); &lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1101980925257123316-1818223931548944889?l=mac-objective-c.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://mac-objective-c.blogspot.com/feeds/1818223931548944889/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mac-objective-c.blogspot.com/2009/03/drawing-in-views-rectangles.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/1818223931548944889?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1101980925257123316/posts/default/1818223931548944889?v=2" /><link rel="alternate" type="text/html" href="http://mac-objective-c.blogspot.com/2009/03/drawing-in-views-rectangles.html" title="Drawing in views: rectangles" /><author><name>MacAddict</name><uri>http://www.blogger.com/profile/09241791588496167155</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://2.bp.blogspot.com/_TZ3tQh6tzPI/SVdz5LI0XkI/AAAAAAAAAAM/xNWOSXjNmjo/S220/Foto+1.jpg" /></author><thr:total>0</thr:total></entry></feed>

