<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
	<channel>
		<title>paulofierro.com</title>
		<link>http://www.paulofierro.com/</link>
		<description>ramblings of a frozen flash dev</description>
		<language>en</language>
		<copyright>Copyright 2006, Paulo Fierro</copyright>
		<pubDate>, 07 Mar 2010 20:51:59 +0200</pubDate>
		<lastBuildDate>, 07 Mar 2010 20:51:59 +0200</lastBuildDate>
		<managingEditor>paulo@paulofierro.com</managingEditor>
		<webMaster>paulo@paulofierro.com</webMaster>
		<image>
			<url>http://www.paulofierro.com/images/rss_logo.jpg</url>
			<title>paulofierro.com</title>
			<link>http://www.paulofierro.com/</link>
		</image>

		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/PauloFierro" /><feedburner:info uri="paulofierro" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>59.57</geo:lat><geo:long>10.42</geo:long><item>
			<title>Removing all subviews - a comparison of Objective-C vs ActionScript</title>
			<link>http://feedproxy.google.com/~r/PauloFierro/~3/FdRD2Rq4tsY/</link>
			<description>&lt;p&gt;In Cocoa Touch a &lt;code&gt;UIView&lt;/code&gt; object is similar to a &lt;code&gt;DisplayObject&lt;/code&gt; in ActionScript. You can add a child to its "display list" by saying:&lt;/p&gt;
&lt;blockquote&gt;
&lt;code&gt;[myMainView addSubview:myOtherView];&lt;/code&gt;
&lt;/blockquote&gt;
&lt;p&gt;To remove the view you say:&lt;/p&gt;
&lt;blockquote&gt;
&lt;code&gt;[myOtherView removeFromSuperview];&lt;/code&gt;
&lt;/blockquote&gt;
&lt;p&gt;As far as I can tell there is no &lt;code&gt;removeChild&lt;/code&gt; like we're used to in AS.&lt;/p&gt;&lt;p&gt;But what if you want to remove &lt;em&gt;all&lt;/em&gt; of the children or subviews? Well, we're not as lucky as containers in Flex with that snazzy &lt;code&gt;removeAllChildren()&lt;/code&gt; method, but we &lt;em&gt;can&lt;/em&gt; loop through the list and tell each subview to remove itself like we do in plain-ol' ActionScript:&lt;/p&gt;
&lt;blockquote&gt;
&lt;code&gt;
while(myMainView.children) {&lt;br /&gt;
	myMainView.removeChildAt(0);&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;
&lt;/blockquote&gt;
&lt;p&gt;In Objective-C this would be:&lt;/p&gt;
&lt;blockquote&gt;
&lt;code&gt;
while([[myMainView subviews] count]) {&lt;br /&gt;
	[[[myMainView subviews] objectAtIndex:0] removeFromSuperview];&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;
&lt;/blockquote&gt;
&lt;p&gt;And this works fine. But today I learned a pretty cool trick. Basically &lt;code&gt;[myMainView subviews]&lt;/code&gt; is an array just like &lt;code&gt;myMainView.children&lt;/code&gt;. And &lt;code&gt;NSArray&lt;/code&gt; has this cool method called &lt;code&gt;makeObjectsPerformSelector&lt;/code&gt; which basically means make every object in the array call whatever method you want them to.&lt;/p&gt;&lt;p&gt;So instead of looping through you can simply say the following:&lt;/p&gt;
&lt;blockquote&gt;
&lt;code&gt;
[[myMainView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
&lt;/code&gt;
&lt;/blockquote&gt;
&lt;p&gt;How cool is that! Not exactly a &lt;code&gt;[myMainView removeAllSubviews]&lt;/code&gt; but still :)&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/PauloFierro/~4/FdRD2Rq4tsY" height="1" width="1"/&gt;</description>
			<pubDate>, 07 Mar 2010 20:48:28 +0200</pubDate>
			<comments>http://www.paulofierro.com/archives/559/#comments</comments>
			<guid isPermaLink="false">http://www.paulofierro.com/archives/559/</guid>
		<feedburner:origLink>http://www.paulofierro.com/archives/559/</feedburner:origLink></item>
		<item>
			<title>Playing with radial menus on the iPhone</title>
			<link>http://feedproxy.google.com/~r/PauloFierro/~3/exdQatWZliQ/</link>
			<description>&lt;p&gt;After watching the &lt;a href="http://www.engadget.com/2010/03/05/microsofts-courier-digital-journal-exclusive-pictures-and-de/?s=t5"&gt;Microsoft Courier videos on Engadget&lt;/a&gt; yesterday I started thinking about radial menus again. There are a &lt;a href="http://www.betterthanflex.com/?p=19"&gt;few examples out there for ActionScript&lt;/a&gt; but I wanted to figure it out in Cocoa Touch.&lt;/p&gt;
&lt;p&gt;So this morning I spent a couple hours throwing some code together. Basically this was the idea:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Listen for touches&lt;/li&gt;
&lt;li&gt;On touch-start, start a timer to show the menu&lt;/li&gt;
&lt;li&gt;On touch-end, kill the timer. The user will have lifted their finger so we don't want to show the menu&lt;/li&gt;
&lt;li&gt;If we're showing the menu, start a timer to remove it once its shown&lt;/li&gt;
&lt;li&gt;If a button is tapped or the timer is triggered remove the menu&lt;/li&gt;
&lt;li&gt;If a button is tapped, do something&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;At the end I tossed in some animation to make it a little nicer visually. A quick vid of it is below and you can &lt;a href="http://paulofierro.com/code/RadialMenu.zip"&gt;grab the Xcode project here&lt;/a&gt;. Its obviously not perfect, but shows shows the idea :)&lt;/p&gt;
&lt;object width="360" height="480"&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=9961378&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /&gt;&lt;embed src="http://vimeo.com/moogaloop.swf?clip_id=9961378&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="360" height="480"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;img src="http://feeds.feedburner.com/~r/PauloFierro/~4/exdQatWZliQ" height="1" width="1"/&gt;</description>
			<pubDate>Sat, 06 Mar 2010 18:06:42 +0200</pubDate>
			<comments>http://www.paulofierro.com/archives/558/#comments</comments>
			<guid isPermaLink="false">http://www.paulofierro.com/archives/558/</guid>
		<feedburner:origLink>http://www.paulofierro.com/archives/558/</feedburner:origLink></item>
	</channel>
</rss>
