<?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:thr="http://purl.org/syndication/thread/1.0" xml:lang="en" xml:base="http://www.madmob.co.za/wp-atom.php">
	<title type="text">MADmob Community - iOS, Android, Blackberry OS, Symbian, Windows Mobile, Phone 7, Bada</title>
	<subtitle type="text">Mobile Application Developer Community</subtitle>

	<updated>2012-01-26T20:17:34Z</updated>

	<link rel="alternate" type="text/html" href="http://www.madmob.co.za" />
	<id>http://www.madmob.co.za/feed/atom/</id>
	

	<generator uri="http://wordpress.org/" version="3.2.1">WordPress</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/madmob" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="madmob" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">madmob</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><entry>
		<author>
			<name>Leonard Ah Kun</name>
						<uri>http://www.cobiinteractive.com</uri>
					</author>
		<title type="html"><![CDATA[Creating traditional looking methods in Objective-C]]></title>
		<link rel="alternate" type="text/html" href="http://www.madmob.co.za/2012/01/26/creating-traditional-looking-methods-in-objective-c/" />
		<id>http://www.madmob.co.za/?p=868</id>
		<updated>2012-01-26T20:17:34Z</updated>
		<published>2012-01-26T20:14:08Z</published>
		<category scheme="http://www.madmob.co.za" term="Coding Tricks" /><category scheme="http://www.madmob.co.za" term="How-to" /><category scheme="http://www.madmob.co.za" term="iOS" /><category scheme="http://www.madmob.co.za" term="convenience" /><category scheme="http://www.madmob.co.za" term="featured" />		<summary type="html"><![CDATA[When new developers decide they want to learn Objective-C, at first glance it is quite intimidating. Mainly because of the method calling syntax that looks like this. [awesomeObject doSomethingAwesomeWith:anotherAwesomeObject and:someOtherAwesomeObject with:awesomeness]; Although this format describes the method you calling better, it often feels a bit verbose when coding as it ]]></summary>
		<content type="html" xml:base="http://www.madmob.co.za/2012/01/26/creating-traditional-looking-methods-in-objective-c/"><![CDATA[<p>When new developers decide they want to learn Objective-C, at first glance it is quite intimidating. Mainly because of the method calling syntax that looks like this.</p>
<p><code><br />
[awesomeObject doSomethingAwesomeWith:anotherAwesomeObject and:someOtherAwesomeObject with:awesomeness];<br />
</code></p>
<p>Although this format describes the method you calling better, it often feels a bit verbose when coding as it requires a lot more to type and a lot more to read. Sometimes you just want a quick method you can call to do things you do a lot.</p>
<p>Lets take the NSString object as an example. There are quite a few methods that I use a often, but always forget how to use them as the methods seem overcomplicated. What I do is create a header (.h) file with common tasks I do in a simpler method that can be called. This is an example some NSString methods I have in my collection.</p>
<p><code><br />
//compare 2 strings</p>
<p>//index of a string found<br />
static inline int CobiStringFind(NSString* string, NSString* subString) {<br />
	NSRange range = [string rangeOfString:subString];<br />
	if (range.location != NSNotFound) {<br />
		return range.location;<br />
	}<br />
	return -1;<br />
}</p>
<p>//get last index of a string<br />
static inline int CobiStringLastIndexOf(NSString* string, NSString *subString) {<br />
	NSRange range = [string rangeOfString:subString options:NSBackwardsSearch];<br />
	if (range.location != NSNotFound) {<br />
		return range.location;<br />
	}<br />
	return -1;<br />
}</p>
<p>//get substring with start and end index<br />
static inline NSString* CobiStringSubString(NSString* string, int startPos, int endPos) {<br />
	return [string substringWithRange:NSMakeRange(startPos, endPos-startPos)];<br />
}</p>
<p>//append character to a string<br />
static inline NSString* CobiStringAppendChar(NSString* string, unichar character) {<br />
	return [NSString stringWithFormat:@"%@%C",string,character];<br />
}<br />
</code></p>
<p>This is quite useful for convenience methods you call a lot. For example if you create a method to translate hex formatted colors into a UIColor, instead of writing a method that looks like [UIColor colorFromHex:@"ffffff"]; you could write a method that looks like ColorFromHex(@&#8221;ffffff&#8221;); which I think is much easier to read and code with.</p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.madmob.co.za/2012/01/26/creating-traditional-looking-methods-in-objective-c/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.madmob.co.za/2012/01/26/creating-traditional-looking-methods-in-objective-c/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>Richard Le Mesurier</name>
					</author>
		<title type="html"><![CDATA[Android to BlackBerry &#8211; regex to remove generics]]></title>
		<link rel="alternate" type="text/html" href="http://www.madmob.co.za/2011/12/07/android-to-blackberry-regex-to-remove-generics/" />
		<id>http://www.madmob.co.za/?p=826</id>
		<updated>2012-01-26T20:16:55Z</updated>
		<published>2011-12-07T08:08:04Z</published>
		<category scheme="http://www.madmob.co.za" term="Android" /><category scheme="http://www.madmob.co.za" term="BlackBerry" /><category scheme="http://www.madmob.co.za" term="Coding Tricks" /><category scheme="http://www.madmob.co.za" term="Cross Platform" /><category scheme="http://www.madmob.co.za" term="featured" />		<summary type="html"><![CDATA[We often have to write the same app across the 3 main platforms: iOS, Android &#38; BlackBerry. And at Cobi, we try to write mostly native apps for performance reasons. So there&#8217;s a lot of porting that goes along with that. (There are many tips on how to write java ]]></summary>
		<content type="html" xml:base="http://www.madmob.co.za/2011/12/07/android-to-blackberry-regex-to-remove-generics/"><![CDATA[<p>We often have to write the same app across the 3 main platforms: iOS, Android &amp; BlackBerry. And at <a title="Cobi Interactive" href="http://www.cobiinteractive.com" target="_blank">Cobi</a>, we try to write mostly native apps for performance reasons. So there&#8217;s a lot of porting that goes along with that.</p>
<p>(There are many tips on how to write java code to make it easier to port between Android and BlackBerry, my favourite is linked below.)</p>
<p>We don&#8217;t share an actual code base between the 2 platforms &#8211; so I need to copy Android code across to my BlackBerry projects. Which means I have all these generics floating around e.g. <code>Hashtable myTable = new Hashtable();</code></p>
<p>Lucky &#8211; Eclipse allows find&#8217;n'replace using regex. I use this: <strong>&lt;[.+[^//&lt;]]+&gt;</strong> (remember to tick &#8220;Regular e<span style="text-decoration: underline">x</span>pressions&#8221;) to find &amp; remove all my generics. Just be aware that this might also find javadoc tags.</p>
<p><img class="size-full wp-image-827" src="http://www.madmob.co.za/wp-content/uploads/2011/12/Untitled.png" alt="" width="454" height="455" /></p>
<p>This tip should save you some time &amp; hassle during your next &#8216;droid to &#8216;Berry port.</p>
<p>For a more advanced, and very interesting discussion about Android/BlackBerry cross-platform code, check out <a title="Porting Android code to BlackBerry" href="http://spin.atomicobject.com/2010/11/15/porting-android-code-to-blackberry/" target="_blank">Porting Android code to BlackBerry</a> at <a title="Atomic Object blog" href="http://spin.atomicobject.com/" target="_blank">Atomic Spin</a>. Also <a title="BlackBerry Ant Tools" href="http://bb-ant-tools.sourceforge.net/" target="_blank">bb-ant-tools</a>.</p>
<p>Whichever path you choose, one thing I can recommend is that you start the project in Android &#8211; the tools &amp; language are just so much better. Save the BlackBerry port, with it&#8217;s related pain, for later.</p>
<p>Feel free to add your own tips for porting native apps between platforms.</p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.madmob.co.za/2011/12/07/android-to-blackberry-regex-to-remove-generics/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.madmob.co.za/2011/12/07/android-to-blackberry-regex-to-remove-generics/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>Richard Le Mesurier</name>
					</author>
		<title type="html"><![CDATA[Javadoc tricks in Eclipse]]></title>
		<link rel="alternate" type="text/html" href="http://www.madmob.co.za/2011/10/20/javadoc-tricks-in-eclipse/" />
		<id>http://www.madmob.co.za/?p=785</id>
		<updated>2011-10-20T09:53:15Z</updated>
		<published>2011-10-20T09:42:37Z</published>
		<category scheme="http://www.madmob.co.za" term="Android" /><category scheme="http://www.madmob.co.za" term="BlackBerry" /><category scheme="http://www.madmob.co.za" term="Coding Tricks" /><category scheme="http://www.madmob.co.za" term="How-to" /><category scheme="http://www.madmob.co.za" term="J2ME" />		<summary type="html"><![CDATA[If you know me, you know I&#8217;m one of &#8220;those&#8221; developers who actually sees value in writing comments &#38; javadoc in my code. Part of that comes from my background of writing code that non-developer managers wanted to tweek/break (amazing how the financial world runs on Excel); part from working ]]></summary>
		<content type="html" xml:base="http://www.madmob.co.za/2011/10/20/javadoc-tricks-in-eclipse/"><![CDATA[<p>If you know me, you know I&#8217;m one of &#8220;those&#8221; developers who actually sees value in writing comments &amp; javadoc in my code. </p>
<p>Part of that comes from my background of writing code that non-developer managers wanted to tweek/break (amazing how the financial world runs on <a title="Excel VBA" href="http://en.wikipedia.org/wiki/Visual_Basic_for_Applications" target="_blank">Excel</a>); part from working in a world-leading java dev house on massive projects. Not to forget such articles as <a href="http://www.joelonsoftware.com/articles/Wrong.html" title="Joel on Software - Making Wrong Code Look Wrong" target="_blank"></a>, or my general tendancy to be rather <a title="CDO" href="http://icanhascheezburger.com/2010/07/08/funny-pictures-i-have-cdo/" target="_blank">CDO</a>.</p>
<p>I like to think the main reason is when I come back to my code months (or a heavy weekend) later, I can still figure out what&#8217;s going on&#8230; this saves me time, making me a nicer guy to be around.</p>
<p><a title="Javadoc" href="http://en.wikipedia.org/wiki/Javadoc" target="_blank">Javadoc</a> is great for this type of thing, and Eclipse&#8217;s auto-complete functionality makes it really easy to write good documentation.</p>
<ol>
<li>To start a javadoc block for a procedure or field, put the cursor above the declaration and type <em>/** ENTER</em>. Eclipse will auto-complete the block for you, ready to type into.</li>
<li>Javadoc&#8217;s power comes from being able to reference other classes from within the comment. This forms hyperlinks enabling the reader to find out more. To do this, start typing the name of the class you want to reference, then <em>CTRL-SPACE</em>. Eclipse should auto-complete the name, and add the link syntax around the class name e.g. typing <em>MyCl CTRL-SPACE</em> completes to <em>{@link MyClass}</em>.</li>
<li>Another way is to add <strong>See also:</strong> references to the bottom of the comment. Use the <em>@see</em> tag to create a hyperlink. e.g. <em>@see MyClass</em> is displayed as <strong>See also:</strong> MyClass.</li>
<li>Parameters &amp; return values can be documented with the <em>@param</em> &amp; <em>@return</em> tags. For personal docs, even I find these to be overkill most of the time, but for api or library code they are essential.</li>
<li>To link to a member of a class, like <em>MyClass.MyInner.helloWorld(String)</em>, the trick is to replace the last &#8220;.&#8221; character with a &#8220;#&#8221;. e.g. <em>@see MyClass.MyInner<strong>#</strong>helloWorld(String)</em></li>
<li>To link to a member of a class you are in, just type <em># CTRL-SPACE</em> and let Eclipse prompt you with the available members to choose from.</li>
<li>To deprecate a method, letting other devs know another method to use, then use the <em>@deprecated</em> tag with a short description e.g. <em>@deprecated use {@link #anotherMethod()} instead</em>.</li>
<li>For the more CDO developers, reserved words like <em>null</em>, <em>true</em>, <em>false</em> can be surrounded by the &lt;code&gt;&lt;code&gt; tags to make them look &#8220;right&#8221;. This is simple to do by just using <em>CTRL-SPACE</em> at the end of the word to auto-complete the tags.</li>
<li>For the creative writers out there, remember this is HTML, so list tags, paragraph tags, line breaks &amp; horizontal lines are all available.</li>
</ol>
<ul>
<li>Lastly, one thing I have found is that the auto-complete does not work directly after a &#8220;.&#8221;. So if you are trying to auto-complete the first word of a new sentence, just type a dummy character and a space before the word (don&#8217;t forget to delete that dummy char afterwards).</li>
</ul>
<p>For more details on various tags allowed, the Oracle manual can be found here: <a title="How to Write Doc Comments for the Javadoc Tool" href="http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html" target="_blank">How to Write Doc Comments for the Javadoc Tool</a>.</p>
<p>hth, and good luck with that CDO&#8230;</p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.madmob.co.za/2011/10/20/javadoc-tricks-in-eclipse/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.madmob.co.za/2011/10/20/javadoc-tricks-in-eclipse/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>Gary McGowan</name>
					</author>
		<title type="html"><![CDATA[Quick and Easy iPhone Gradients]]></title>
		<link rel="alternate" type="text/html" href="http://www.madmob.co.za/2011/08/11/quick-and-easy-iphone-gradients/" />
		<id>http://www.madmob.co.za/?p=748</id>
		<updated>2011-08-11T14:43:09Z</updated>
		<published>2011-08-11T14:43:09Z</published>
		<category scheme="http://www.madmob.co.za" term="How-to" /><category scheme="http://www.madmob.co.za" term="iOS" /><category scheme="http://www.madmob.co.za" term="gradients" />		<summary type="html"><![CDATA[The market for iPhone and iPad apps is competitive and sometimes a bit of extra eye-candy goes a long way. For a couple of projects I have had to give various items a gradient shaded background. There are two ways to do this. Core Graphics or Core Animation. Gradients in ]]></summary>
		<content type="html" xml:base="http://www.madmob.co.za/2011/08/11/quick-and-easy-iphone-gradients/"><![CDATA[<p>The market for iPhone and iPad apps is competitive and sometimes a bit of extra eye-candy goes a long way. For a couple of projects I have had to give various items a gradient shaded background. There are two ways to do this. Core Graphics or Core Animation. Gradients in Core Graphics give you more customization and more control, but are more complex to implement, while gradients in Core Animation are simple, but may not be able to do everything you need. Here we are going to look are the fast Core Animation approach.</p>
<p>Make sure you <code>#import &lt;QuartzCore/QuartzCore.h&gt;</code></p>
<p>To make a simple rectangular gradient all we need is to add a CAGradientLayer:</p>
<p><code>CAGradientLayer * gradientLayer = [CAGradientLayer layer];<br />
gradientLayer.frame = CGRectMake(0, 0, 80, 60);<br />
gradientLayer.colors = [NSArray arrayWithObjects:(id)[[UIColor redColor] CGColor],(id)[[UIColor greenColor] CGColor], nil];<br />
[self.window.layer addSublayer:gradientLayer];</code></p>
<p>This produces a rectangle that can be used in any view:<br />
<a href="http://www.madmob.co.za/wp-content/uploads/2011/08/rectangle.png"><img class="aligncenter size-medium wp-image-822" src="http://www.madmob.co.za/wp-content/uploads/2011/08/rectangle-300x156.png" alt="" width="300" height="156" /></a><br />
We can give the layer rounded corners by adding:</p>
<p><code>gradientLayer.cornerRadius = 10;</code><br />
<a href="http://www.madmob.co.za/wp-content/uploads/2011/08/rectangle_rounded.jpg"><img class="aligncenter size-full wp-image-815" src="http://www.madmob.co.za/wp-content/uploads/2011/08/rectangle_rounded.jpg" alt="" width="87" height="68" /></a><br />
For more complex shapes we can set a mask for the gradient layer using a CAShapeLayer:<br />
<code>//Make shape – Triangle<br />
CGMutablePathRef path = CGPathCreateMutable();<br />
CGPathMoveToPoint(path, NULL,40.0f, 0.0f);<br />
CGPathAddLineToPoint (path, NULL,80.0f, 60.0f);<br />
CGPathAddLineToPoint (path, NULL,0.0f, 60.0f);<br />
CGPathCloseSubpath(path);</code></p>
<p><code> </code></p>
<p><code>//Shape layer<br />
CAShapeLayer * mask = [CAShapeLayer layer];<br />
mask.path = path;<br />
[gradientLayer setMask:mask];</code></p>
<p><code>//release path<br />
CGPathRelease(path);</code><br />
<a href="http://www.madmob.co.za/wp-content/uploads/2011/08/triangle.jpg"><img class="aligncenter size-full wp-image-816" src="http://www.madmob.co.za/wp-content/uploads/2011/08/triangle.jpg" alt="" width="90" height="67" /></a></p>
<p>UIButton with a gradient:</p>
<p><a href="http://www.madmob.co.za/wp-content/uploads/2011/08/button.jpg"><img class="aligncenter size-full wp-image-817" src="http://www.madmob.co.za/wp-content/uploads/2011/08/button.jpg" alt="" width="135" height="59" /></a></p>
<p>&nbsp;</p>
<p>The graph I made for a project using Core Animation layers:<br />
<a href="http://www.madmob.co.za/wp-content/uploads/2011/08/graph1.jpg"><img class="aligncenter size-full wp-image-818" src="http://www.madmob.co.za/wp-content/uploads/2011/08/graph1.jpg" alt="" width="269" height="96" /></a></p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.madmob.co.za/2011/08/11/quick-and-easy-iphone-gradients/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.madmob.co.za/2011/08/11/quick-and-easy-iphone-gradients/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>Richard Le Mesurier</name>
					</author>
		<title type="html"><![CDATA[Eclipse productivity tricks]]></title>
		<link rel="alternate" type="text/html" href="http://www.madmob.co.za/2011/07/15/eclipse-productivity-tricks/" />
		<id>http://www.madmob.co.za/?p=712</id>
		<updated>2012-01-26T20:16:37Z</updated>
		<published>2011-07-15T07:22:53Z</published>
		<category scheme="http://www.madmob.co.za" term="Coding Tricks" /><category scheme="http://www.madmob.co.za" term="How-to" /><category scheme="http://www.madmob.co.za" term="focus" />		<summary type="html"><![CDATA[If you&#8217;re like me, you never bother to &#8220;learn&#8221; the productivity shortcuts of any IDE &#8211; but when they happen to stumble through your life accidentally, you are always surprised &#8211; &#8220;Wow! You can do THAT?!&#8221; This normally followed by feeling a bit silly for not reading the keyboard shortcut ]]></summary>
		<content type="html" xml:base="http://www.madmob.co.za/2011/07/15/eclipse-productivity-tricks/"><![CDATA[<p>If you&#8217;re like me, you never bother to &#8220;learn&#8221; the productivity shortcuts of any IDE &#8211; but when they happen to stumble through your life accidentally, you are always surprised &#8211; &#8220;Wow! You can do THAT?!&#8221; This normally followed by feeling a bit silly for not reading the keyboard shortcut list recently (<strong><em>Ctrl + Shift + L</em></strong>). There are just so many that I won&#8217;t use in an average day.</p>
<p>So you go through life thinking<em> <strong>Ctrl + space</strong></em> is the best thing since sliced bread (it IS if you know how badly some other IDE&#8217;s implement it), and that&#8217;s that.</p>
<p>Anyway here are some that I use almost all the time, and have increased my productivity greatly (dreadful how after so long, I have so few that I remember):</p>
<ul>
<li>Rename object/method/field:<strong><em> Alt + Shift + r</em></strong>.<br />
If you program like me, you often have to refactor on the run &#8211; this one is great for that. Beats the old way of find &#8216;n&#8217; replace. And it goes very nicely with&#8230;&#8230;.</li>
<li>Select word where cursor is:<em> <strong>Alt +Shift + UP</strong></em><br />
Simply selects the word where the cursor is. Press again to expand the selection to the fully qualified name. Again to select the line, then paragraph. <strong><em>Alt + Shift + DOWN</em></strong> undoes this process. Hours of fun to be had here.</li>
<li>Quick Fix: <em><strong>Ctrl + 1</strong></em><br />
Scenario: You have a method that returns a common Object, and you want to cast it to MyObject &#8211; particularly useful for returning objects out of Hashtables, pre generics. So if like me, you have to use the mouse, lose a microsecond, lose your context, and let Eclipse suggest a fix for you. If you are clever (like the new me), press<strong><em> Ctrl + 1</em></strong>.</li>
<li>Auto-Import:<em><strong> Ctrl + Shift + o</strong></em><br />
Automatically corrects your imports. This and the next might appeal to the OCDs.</li>
<li>Auto-Format: <em><strong>Ctrl + Shift + f</strong></em><br />
Auto formats your code according to the user prefs. I love this one (see comment above).</li>
<li>Extract local variable: <em><strong>Alt + Shift + l</strong></em><br />
This is one I&#8217;ve been playing around with a bit, normally during debugging phase. I find myself wanting to log field values quite a lot when making method calls, but normally I would not create a temp variable before calling said method e.g. doSomething(anObject.getValue()). So a quick selection of &#8220;anObject.getValue()&#8221; and wham &#8211; we have a temp variable that can be logged before calling the method.</li>
<li>Extract new method: <em><strong>Alt + Shift + m</strong></em><br />
This is great for refactoring &#8211; you select a block of code and use this shortcut which creates a new method based on the selection. Eclipse even identifies what parameters your new method should take.</li>
<li>Easy commenting:
<ul>
<li><em><strong>Ctrl + /</strong></em> comments out the line your cursor is on, or the lines that are selected (or partially selected). If line is commented, this will remove comments. e.g. <code>// this is a comment</code></li>
<li><em><strong>Ctrl + Shift + /</strong></em> comments out the selection. e.g. <code>/*this was selected*/</code>.</li>
<li><em><strong>Ctrl + Shift + c</strong></em> comments out the selection. In java edit mode, this is the same as using <em><strong>Ctrl + /</strong></em>. But this can also be used in Android&#8217;s xml editor, making this very useful. e.g. <code>&lt;!-- comment in xml --&gt;</code>.
</ul>
</li>
</ul>
<p>Of course there are loads more. I think it depends on your type of work, which things do you spend a lot of time doing. In my previous work, <strong><em>Ctrl + Space</em></strong> really was all I needed. Its nice to know that we humans are capable of learning as we grow&#8230;</p>
<p>hth ymmv</p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.madmob.co.za/2011/07/15/eclipse-productivity-tricks/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.madmob.co.za/2011/07/15/eclipse-productivity-tricks/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>Altus van der Merwe</name>
					</author>
		<title type="html"><![CDATA[Objective-C: Blurry UIView]]></title>
		<link rel="alternate" type="text/html" href="http://www.madmob.co.za/2011/06/29/objective-c-blurry-uiview/" />
		<id>http://www.madmob.co.za/?p=724</id>
		<updated>2012-01-26T20:16:28Z</updated>
		<published>2011-06-29T19:15:18Z</published>
		<category scheme="http://www.madmob.co.za" term="iOS" /><category scheme="http://www.madmob.co.za" term="focus" /><category scheme="http://www.madmob.co.za" term="ios" /><category scheme="http://www.madmob.co.za" term="uilabel" />		<summary type="html"><![CDATA[If you&#8217;ve been coding Objective-C interfaces for a while you will know that you set the position of a view using it&#8217;s frame property. This property is a CGRect which is made up of four float values. newView.frame = CGRectMake(0.0, 0.0, 100.0, 100.0); At first these floats were quiet an ]]></summary>
		<content type="html" xml:base="http://www.madmob.co.za/2011/06/29/objective-c-blurry-uiview/"><![CDATA[<p>If you&#8217;ve been coding Objective-C interfaces for a while you will know that you set the position of a view using it&#8217;s frame property. This property is a CGRect which is made up of four float values. <code> newView.frame = CGRectMake(0.0, 0.0, 100.0, 100.0); </code></p>
<p>At first these floats were quiet an annoyance because when debugging using <code>NSLog()</code> to check if frames were set correctly you have to use <code>NSLog(@"%f",newView.frame.origin.x);</code> and this is printed as a decimal number i.e. 0.00000</p>
<p>After getting used to this and starting a project that required 3 columns down the screen I thought that I could finally use the floats to their full effect. So I divided the space neatly by three and drew UILabels. <code> UILabel *firstLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 1024/3, 768.0)]; </code></p>
<p>Unfortunately this caused my UILabels to become fuzzy or blurry. After an extensive google search  I found out that you should <strong>NOT</strong> be setting your frames using float values. Although CGRects take float values, when a UIView gets drawn and it has a decimal value in the frame it will blur that value to the nearest integer. This makes sense when you remember that the value you are giving is ment to represent a pixel value and a view cannot end halfway through a pixel.</p>
<p>So you should ensure that your frame does not contain any decimal values. An easy way to do this is to use the <code>roundf()</code> function. If placed around all 4 values in your frame you will always have an integer value, however this is a lot of extra code and you only have to do it where there is a possibility of having a decimal value. So my above label example became<br />
<code> UILabel *firstLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, roundf(1024/3), 768.0)]; </code></p>
<p>Using a views <code>center</code> property it is possible to get a point with a .5 value (any view with a width or height that is odd will give you a .5 value). Using a views center to position another view should therefore be done using roundf(). For example say you have a white view and you want to cover it from the middle to the bottom right corner with red:</p>
<pre>UIView *bigView = [[UIView alloc] initWithFrame:CGRectMake(30.0, 30.0, 67.0, 71.0)];
bigView.backgroundColor = [UIColor whiteColor];
[self addSubview:bigView];

UIView *smallView = [[UIView alloc] initWithFrame:CGRectMake(
                                roundf(bigView.center.x),
                                roundf(bigView.center.y),
                                roundf(bigView.frame.size.width/2),
                                roundf(bigView.frame.size.height/2)
                                                                                                )];
smallView.backgroundColor = [UIColor redColor];
[self addSubview:smallView];

[bigView release];
[smallView release];</pre>
]]></content>
		<link rel="replies" type="text/html" href="http://www.madmob.co.za/2011/06/29/objective-c-blurry-uiview/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.madmob.co.za/2011/06/29/objective-c-blurry-uiview/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>Stephen Asherson</name>
					</author>
		<title type="html"><![CDATA[Deploying a BlackBerry app for OTA installation]]></title>
		<link rel="alternate" type="text/html" href="http://www.madmob.co.za/2011/06/24/deploying-a-blackberry-app-for-ota-installation/" />
		<id>http://www.madmob.co.za/?p=729</id>
		<updated>2012-01-26T20:17:02Z</updated>
		<published>2011-06-24T12:07:28Z</published>
		<category scheme="http://www.madmob.co.za" term="BlackBerry" /><category scheme="http://www.madmob.co.za" term="How-to" /><category scheme="http://www.madmob.co.za" term="ota" />		<summary type="html"><![CDATA[When testing a build of a BlackBerry app, one method to deploy the app on a BlackBerry OTA is to host all of the application COD files and a main JAD file with the relevant details of each COD file in it. Once hosted, one can point the BlackBerry device ]]></summary>
		<content type="html" xml:base="http://www.madmob.co.za/2011/06/24/deploying-a-blackberry-app-for-ota-installation/"><![CDATA[<p>When testing a build of a BlackBerry app, one method to deploy the app on a BlackBerry OTA is to host all of the application COD files and a main JAD file with the relevant details of each COD file in it. Once hosted, one can point the BlackBerry device to the JAD file being hosted and the application COD files will be installed on the device.</p>
<p>While this isn&#8217;t such a problem with single projects in isolation, anyone who has had to do this manually where multiple projects (such as library projects) are involved in the deployment of a single app, will known that the process of assembling the COD details into a single JAD file is rather menial and in general quite insufferable. Fortunately, the BlackBerry JDE comes with a tool called <em><strong>updatejad.exe</strong></em> and works as follows:</p>
<p>Let&#8217;s use a main project name of <em><strong>Peanut</strong></em> and peanut relies on the library projects <em><strong>Raisin</strong></em> and <em><strong>Salt</strong></em>. To assemble the Peanut.jad file with the COD details of all the projects, one can use the following command:</p>
<p style="padding-left: 30px;"><strong>updatejad.exe Peanut.jad Raisin.jad Salt.jad</strong></p>
<p>I find it easiest just to copy the necessary JAD and COD files to a single directory when running this command. There you go&#8230; you now have a deployable JAD file to host along with all of the application COD file <img src='http://www.madmob.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.madmob.co.za/2011/06/24/deploying-a-blackberry-app-for-ota-installation/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.madmob.co.za/2011/06/24/deploying-a-blackberry-app-for-ota-installation/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>Dennis Burford</name>
					</author>
		<title type="html"><![CDATA[Apps World 2011 Gallery]]></title>
		<link rel="alternate" type="text/html" href="http://www.madmob.co.za/2011/06/03/apps-world-2011-gallery/" />
		<id>http://www.madmob.co.za/?p=692</id>
		<updated>2011-06-29T19:23:21Z</updated>
		<published>2011-06-03T10:14:42Z</published>
		<category scheme="http://www.madmob.co.za" term="BlackBerry" /><category scheme="http://www.madmob.co.za" term="Microsoft" /><category scheme="http://www.madmob.co.za" term="News" /><category scheme="http://www.madmob.co.za" term="Nokia" /><category scheme="http://www.madmob.co.za" term="Phone 7" /><category scheme="http://www.madmob.co.za" term="conference" />		<summary type="html"><![CDATA[Here are some pics from the AppsWorld / Social Media World Forum 2011 Conference that concluded yesterday in Cape Town.]]></summary>
		<content type="html" xml:base="http://www.madmob.co.za/2011/06/03/apps-world-2011-gallery/"><![CDATA[<p>Here are some pics from the AppsWorld / Social Media World Forum 2011 Conference that concluded yesterday in Cape Town.</p>
<div id="attachment_689" class="wp-caption alignleft" style="width: 310px"><a href="http://www.madmob.co.za/wp-content/uploads/2011/06/nokia_lounge-1024x575.jpg"><img src="http://www.madmob.co.za/wp-content/uploads/2011/06/nokia_lounge-300x168.jpg" alt="Nokia Lounge" title="nokia_lounge" width="300" height="168" class="size-medium wp-image-689" /></a><p class="wp-caption-text">Nokia Lounge -- attracting developers any way they can!</p></div>
<div id="attachment_687" class="wp-caption alignright" style="width: 310px"><a href="http://www.madmob.co.za/wp-content/uploads/2011/06/dev_zone-1024x575.jpg"><img src="http://www.madmob.co.za/wp-content/uploads/2011/06/dev_zone-300x168.jpg" alt="Developer Zone" title="dev_zone" width="300" height="168" align="right" class="size-medium wp-image-687" /></a><p class="wp-caption-text">Developer Zone </p></div>
<div id="attachment_686" class="wp-caption alignleft" style="width: 310px"><a href="http://www.madmob.co.za/wp-content/uploads/2011/06/blackberry_stand-1024x575.jpg"><img src="http://www.madmob.co.za/wp-content/uploads/2011/06/blackberry_stand-300x168.jpg" alt="BlackBerry stand" title="blackberry_stand" width="300" height="168" class="size-medium wp-image-686" /></a><p class="wp-caption-text">BlackBerry stand</p></div>
<div id="attachment_690" class="wp-caption alignright" style="width: 310px"><a href="http://www.madmob.co.za/wp-content/uploads/2011/06/playbook-1024x575.jpg"><img src="http://www.madmob.co.za/wp-content/uploads/2011/06/playbook-300x168.jpg" alt="" title="playbook" width="300" height="168" class="size-medium wp-image-690" /></a><p class="wp-caption-text">A much-fondled PlayBook on show</p></div>
<div id="attachment_697" class="wp-caption alignleft" style="width: 310px"><a href="http://www.madmob.co.za/wp-content/uploads/2011/06/ms_stand-1024x575.jpg"><img src="http://www.madmob.co.za/wp-content/uploads/2011/06/ms_stand-300x168.jpg" alt="Microsoft stand" title="ms_stand" width="300" height="168" class="size-medium wp-image-697" /></a><p class="wp-caption-text">Microsoft stand -- a little sparse, guys!</p></div>
<div id="attachment_691" class="wp-caption alignright" style="width: 310px"><a href="http://www.madmob.co.za/wp-content/uploads/2011/06/session-1024x575.jpg"><img src="http://www.madmob.co.za/wp-content/uploads/2011/06/session-300x168.jpg" alt="Paid-for session" title="session" width="300" height="168" class="size-medium wp-image-691" /></a><p class="wp-caption-text">Paid-for session, no riff-raff allowed</p></div>
<div id="attachment_688" class="wp-caption alignleft" style="width: 310px"><a href="http://www.madmob.co.za/wp-content/uploads/2011/06/free_coffee_nokia-1024x575.jpg"><img src="http://www.madmob.co.za/wp-content/uploads/2011/06/free_coffee_nokia-300x168.jpg" alt="Nokia Free Coffee" title="free_coffee_nokia" width="300" height="168" class="size-medium wp-image-688" /></a><p class="wp-caption-text">The queue for free coffee in the Nokia Lounge</p></div>
<div id="attachment_685" class="wp-caption alignright" style="width: 310px"><a href="http://www.madmob.co.za/wp-content/uploads/2011/06/angry_bird-1024x575.jpg"><img src="http://www.madmob.co.za/wp-content/uploads/2011/06/angry_bird-300x168.jpg" alt="Angry Bird Keyrings" title="angry_bird" width="300" height="168" class="size-medium wp-image-685" /></a><p class="wp-caption-text">Angry Bird, anyone?</p></div>
]]></content>
		<link rel="replies" type="text/html" href="http://www.madmob.co.za/2011/06/03/apps-world-2011-gallery/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.madmob.co.za/2011/06/03/apps-world-2011-gallery/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>Leonard Ah Kun</name>
						<uri>http://www.cobiinteractive.com</uri>
					</author>
		<title type="html"><![CDATA[Opening custom files in iOS with your app]]></title>
		<link rel="alternate" type="text/html" href="http://www.madmob.co.za/2011/05/31/opening-custom-files-in-ios-with-your-app/" />
		<id>http://www.madmob.co.za/?p=663</id>
		<updated>2011-06-29T19:26:57Z</updated>
		<published>2011-05-31T11:58:33Z</published>
		<category scheme="http://www.madmob.co.za" term="How-to" /><category scheme="http://www.madmob.co.za" term="iOS" /><category scheme="http://www.madmob.co.za" term="Document handling" /><category scheme="http://www.madmob.co.za" term="featured" />		<summary type="html"><![CDATA[iOS allows you to open custom files with your app. You can send various files to other apps from your app, or receive files to your app from another app. The simplest example would be attachments in Mail. This will also work in Safari. Here, I will show you how ]]></summary>
		<content type="html" xml:base="http://www.madmob.co.za/2011/05/31/opening-custom-files-in-ios-with-your-app/"><![CDATA[<p>iOS allows you to open custom files with your app. You can send various files to other apps from your app, or receive files to your app from another app. The simplest example would be attachments in Mail. This will also work in Safari.</p>
<p><a href="http://www.madmob.co.za/wp-content/uploads/2011/05/IMG_0347.png"><img src="http://www.madmob.co.za/wp-content/uploads/2011/05/IMG_0347-200x300.png" alt="" title="IMG_0347" width="200" height="300" class="aligncenter size-medium wp-image-664" /></a></p>
<p>Here, I will show you how to enable and handle this in your app. For this example, I have created a blank View-Based Application project called OpenMe. To add a file handling type you have to edit details in the Info.plist file. The 2 properties of interest are &#8220;Document types&#8221; and &#8220;Exported Type UTIs&#8221;.</p>
<p><a href="http://www.madmob.co.za/wp-content/uploads/2011/05/Screen-shot-2011-05-31-at-11.50.00-AM.png"><img src="http://www.madmob.co.za/wp-content/uploads/2011/05/Screen-shot-2011-05-31-at-11.50.00-AM-300x193.png" alt="" title="Screen shot 2011-05-31 at 11.50.00 AM" width="300" height="193" class="aligncenter size-medium wp-image-665" /></a></p>
<p>Under &#8220;Document types&#8221;, add an item. This item must contain the following properties. Replace the necessary details of your custom file type here. For this example, we are adding a document with extension .openme to be handled.</p>
<p>Document Type Name: OpenMe File<br />
(Optional) Icon File Name: Icon.png<br />
Handler rank: Owner<br />
Document Content Type UTIs->Item 0: com.cobi.openme<br />
CFBundleTypeExtensions->Item 0: openme</p>
<p>Under Exported Type UTIs, add an item with the following properties. Again, replace the necessary details of your custom file type here.<br />
Description: Open Me Description<br />
(Optional) Conforms to UTIs: <i>UTI e.g. public.plain-text to handle .txt files</i><br />
Identifier: com.cobi.openme<br />
Equivalent Types->public.filename-extension: openme</p>
<p>Your property list should now look like the screenshot below.<br />
<a href="http://www.madmob.co.za/wp-content/uploads/2011/05/Screen-shot-2011-05-31-at-1.25.43-PM.png"><img src="http://www.madmob.co.za/wp-content/uploads/2011/05/Screen-shot-2011-05-31-at-1.25.43-PM-300x193.png" alt="" title="Screen shot 2011-05-31 at 1.25.43 PM" width="300" height="193" class="aligncenter size-medium wp-image-666" /></a></p>
<p>You can compile and run this on your device. Send yourself a mail with the .openme extension to test.</p>
<p>When the attachment gets sent to the app, it is saved in the apps documents directory and is required to be managed by the app (i.e. it will not automatically be deleted).</p>
<p>To handle the file in your app, these methods are called.</p>
<p>This gets called if the app is not already launched. </p>
<pre class="brush: objc; title: ; notranslate">
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
</pre>
<p>To acquire the path to the file, use this method.</p>
<pre class="brush: objc; title: ; notranslate">
NSURL *url = (NSURL *)[launchOptions valueForKey:UIApplicationLaunchOptionsURLKey];
</pre>
<p>This gets called on resuming an app.</p>
<pre class="brush: objc; title: ; notranslate">
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;
</pre>
<p>To check if the url is valid, this can be done simply by</p>
<pre class="brush: objc; title: ; notranslate">
if ([url isFileURL]) {}
</pre>
<p>For more info on UTI&#8217;s and document handling, checkout these links.<br />
<a href="http://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/RegisteringtheFileTypesYourAppSupports.html#//apple_ref/doc/uid/TP40010411-SW1">Registering the File Types Your App Supports</a><br />
<a href="http://developer.apple.com/library/mac/#documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html">System-Declared Uniform Type Identifiers</a><br />
<a href="http://developer.apple.com/library/mac/#documentation/FileManagement/Conceptual/understanding_utis/understand_utis_intro/understand_utis_intro.html">Introduction to Uniform Type Identifiers Overview</a></p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.madmob.co.za/2011/05/31/opening-custom-files-in-ios-with-your-app/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.madmob.co.za/2011/05/31/opening-custom-files-in-ios-with-your-app/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	</entry>
		<entry>
		<author>
			<name>Dennis Burford</name>
					</author>
		<title type="html"><![CDATA[Apps World Africa 2011 in Cape Town]]></title>
		<link rel="alternate" type="text/html" href="http://www.madmob.co.za/2011/05/25/appsworld-africa/" />
		<id>http://www.madmob.co.za/?p=645</id>
		<updated>2012-01-26T20:16:11Z</updated>
		<published>2011-05-25T09:14:03Z</published>
		<category scheme="http://www.madmob.co.za" term="Android" /><category scheme="http://www.madmob.co.za" term="BlackBerry" /><category scheme="http://www.madmob.co.za" term="iOS" /><category scheme="http://www.madmob.co.za" term="J2ME" /><category scheme="http://www.madmob.co.za" term="News" /><category scheme="http://www.madmob.co.za" term="Nokia" /><category scheme="http://www.madmob.co.za" term="Phone 7" /><category scheme="http://www.madmob.co.za" term="apps world conference" />		<summary type="html"><![CDATA[Next week sees a major event on the calendar for mobile app developers. <a href="http://www.apps-world.net/africa/ ">Appsworld Africa</a> takes place at the Cape Town International Convention Center (CTICC) on 1-2 June 2011. These two days will be packed with technical workshops from industry leaders like Google, BlackBerry, Microsoft and Nokia.]]></summary>
		<content type="html" xml:base="http://www.madmob.co.za/2011/05/25/appsworld-africa/"><![CDATA[<p>Next week sees a major event on the calendar for mobile app developers. <a href="http://www.apps-world.net/africa/ ">Appsworld Africa</a> takes place at the Cape Town International Convention Center (CTICC) on 1-2 June 2011. These two days will be packed with workshops from industry leaders like Google, BlackBerry, Microsoft and Nokia. Also on the agenda are several talks about monetizing your apps &#8212; an obvious, but key part of the equation routinely overlooked by many a developer.</p>
<p>The conference organizers have done a great job in attracting the big boys in our industry. There are several free-to-attend <a href="http://www.apps-world.net/africa/workshops/workshop-agenda">workshops</a> as part of the &#8216;developer zone&#8217;. The first day will see Droidworld presenting an introduction to Android development. Nokia have sponsored a workshop later in the day which includes several influential speakers. Also on day 1 is a presentation by Robert Virkus, CEO of Enough Software and creator of J2ME Polish.</p>
<p>On Day 2, BlackBerry is putting on a <a href="http://www.apps-world.net/blog/2011/05/uncategorized/blackberry-to-host-app-developer-masterclass-appsworld-africa/#more-690">free developer masterclass</a>, hosted by Michael Weitzel, the senior application development consultant for RIM South Africa. Immediately thereafter, Microsoft present a workshop on Windows Phone 7 development. </p>
<p>There is also a paid-for stream of workshops over the two days which cover mostly business topics. At £295, it might be a little pricey for startups, but there will be some good stuff so it may be worth while.</p>
<p>Conferences like these serve as a much needed spur for the local mobile dev community, which is growing at a healthy rate. With mobile penetration in South Africa particularly high, we have every reason to believe that our country can be a leader in this field, within Africa and globally. Others have recognized this, which is why we are seeing more and more investment and interest from the world.</p>
<p>Running alongside the Appsworld conference will be the <a href="http://www.socialmedia-forum.com/africa/ ">Social Media World Forum</a>. These two fields &#8212; mobile apps and social media &#8212; are intimately intertwined. Those working in either field can ill afford to ignore the other. Users expect social media to be woven into almost every app at some level, and the ideal platform for social media are those devices we carry with us wherever we are. For these reasons, don&#8217;t neglect to have a look at the <a href="http://www.apps-world.net/africa/workshops/workshop-agenda">SMWF agenda</a> too.</p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.madmob.co.za/2011/05/25/appsworld-africa/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.madmob.co.za/2011/05/25/appsworld-africa/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	</entry>
	</feed>

