<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Whomwah.com &#187; cocoa</title>
	<atom:link href="http://whomwah.com/tag/cocoa/feed/" rel="self" type="application/rss+xml" />
	<link>http://whomwah.com</link>
	<description>The website of Duncan Robertson, currently computing for the BBC</description>
	<lastBuildDate>Fri, 06 Jan 2012 12:55:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>TellyBox Update 1.8 (Fixed for iPlayer change)</title>
		<link>http://whomwah.com/2010/08/23/tellybox-update-1-8/</link>
		<comments>http://whomwah.com/2010/08/23/tellybox-update-1-8/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 15:38:05 +0000</pubDate>
		<dc:creator>Duncan</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[BBC]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[tellybox]]></category>

		<guid isPermaLink="false">http://whomwah.com/?p=2037</guid>
		<description><![CDATA[A quick post to say that TellyBox has been updated to fix a bug that was stopping and telly being shown (thanks Joe for the heads up). This was caused by iPlayer changing their implementation code (something out of my control). Whilst fixing this bug, I also change the schedule fetching code to use the [...]]]></description>
			<content:encoded><![CDATA[<p>A quick post to say that <a href="http://whomwah.github.com/tellybox/">TellyBox</a> has been updated to fix a bug that was stopping and telly being shown (thanks Joe for the heads up). This was caused by <a href="http://bbc.co.uk/iplayer/tv">iPlayer</a> changing their implementation code (something out of my control).  Whilst fixing this bug, I also change the schedule fetching code to use the <a href="http://www.bbc.co.uk/programmes">BBC Programmes</a> <a href="http://www.bbc.co.uk/bbcone/programmes/schedules/london.json">JSON feed</a> which makes the app smaller and faster.</p>
]]></content:encoded>
			<wfw:commentRss>http://whomwah.com/2010/08/23/tellybox-update-1-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nextKeyView and moving between NSTextfield and NSButton</title>
		<link>http://whomwah.com/2010/05/26/nextkeyviewtips/</link>
		<comments>http://whomwah.com/2010/05/26/nextkeyviewtips/#comments</comments>
		<pubDate>Wed, 26 May 2010 15:57:32 +0000</pubDate>
		<dc:creator>Duncan</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://whomwah.com/?p=1913</guid>
		<description><![CDATA[This caught me out today, so I thought I&#8217;d share to save someone else scratching their head. The problem I was having was thus. In interface builder I had a window with an NSTextField and an NSButton. I want to be able to tab between them. I did what I thought was correct: Set the [...]]]></description>
			<content:encoded><![CDATA[<p>This caught me out today, so I thought I&#8217;d share to save someone else scratching their head. The problem I was having was thus. In interface builder I had a window with an <strong>NSTextField</strong> and an <strong>NSButton</strong>. I want to be able to tab between them. I did what I thought was correct:</p>
<ol>
<li>Set the <strong>intialFirstResponser</strong> for the <strong>NSWindow</strong> to be my <strong>NSTextField</strong></li>
<li>Set the <strong>NSTextField</strong> <strong>nextKeyView</strong> to be the <strong>NSButton</strong></li>
<li>Set the <strong>NSButton</strong> <strong>nextKeyView</strong> to be my <strong>NSTextField</strong></li>
</ol>
<p>But this was not working in the app! It Turns out that in the <em>Apple > System Preferences > Keyboard</em> there is a setting that allows you to press Tab to move keyboard focus between:</p>
<ul>
<li>Text boxes and lists only</li>
<li>All controls</li>
</ul>
<p>I think the top one is set by default. Once changed to <em>All controls</em> everything worked as expected.</p>
]]></content:encoded>
			<wfw:commentRss>http://whomwah.com/2010/05/26/nextkeyviewtips/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Cocoa to keep an app window always on top</title>
		<link>http://whomwah.com/2009/04/11/using-cocoa-to-keep-an-app-window-always-on-top/</link>
		<comments>http://whomwah.com/2009/04/11/using-cocoa-to-keep-an-app-window-always-on-top/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 16:39:21 +0000</pubDate>
		<dc:creator>Duncan</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[OSX]]></category>

		<guid isPermaLink="false">http://whomwah.com/?p=1393</guid>
		<description><![CDATA[Sometimes you want your application to keep one of it&#8217;s windows always-on-top. A chat application like Adium for example, allows you to keep your conversation window always-on-top so you can follow the conversation whilst still using other applications. In the TellyBox application I wrote, this functionality is also very useful, as you can watch tv [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you want your application to keep one of it&#8217;s windows always-on-top. A chat application like <a href="http://www.adiumx.com/">Adium</a> for example, allows you to keep your conversation window always-on-top so you can follow the conversation whilst still using other applications. In the <a href="http://whomwah.github.com/tellybox/">TellyBox</a> application I wrote, this functionality is also very useful, as you can watch tv whilst still working in other applications.</p>
<p>So the basic implementation was fairly simple. You just use the <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html#//apple_ref/doc/uid/20000013-BCIDIEDF">windowDidResignMain notification</a>, and then re-set the window level a more fitting one. Below I have also wrapped around a preference setting:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>windowDidResignMain<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSNotification</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>notification
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// It's always nicer if the user has a choice</span>
  <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSUserDefaults</span> standardUserDefaults<span style="color: #002200;">&#93;</span> boolForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;DefaultAlwaysOnTop&quot;</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> <span style="color: #a61390;">YES</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
    <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>self window<span style="color: #002200;">&#93;</span> setLevel<span style="color: #002200;">:</span>NSFloatingWindowLevel<span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
    <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>self window<span style="color: #002200;">&#93;</span> setLevel<span style="color: #002200;">:</span>NSNormalWindowLevel<span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>My <a href="http://whomwah.github.com/tellybox/">TellyBox</a> application allows you to go fullscreen via the existing Flash application embedded in a webkit view. Using just the basic implementation meant that when going into fullscreen mode the frame of the original window remained in view. To fix this I added this extra bit of code, which gets used via the firing of another useful notification <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html#//apple_ref/doc/uid/20000013-BCIEBCEI">windowDidBecomeMain</a> :</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>windowDidBecomeMain<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSNotification</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>notification
<span style="color: #002200;">&#123;</span>
  <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>self window<span style="color: #002200;">&#93;</span> setLevel<span style="color: #002200;">:</span>NSNormalWindowLevel<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>which sets the window level back to it&#8217;s default value of 0 when it becomes the main window i.e when you select it.</p>
<p>I hope this little snippet helps people trying to achieve the same effect in their apps.</p>
]]></content:encoded>
			<wfw:commentRss>http://whomwah.com/2009/04/11/using-cocoa-to-keep-an-app-window-always-on-top/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Lookup &#8211; A simple Mac utility that wraps ldapsearch</title>
		<link>http://whomwah.com/2009/04/07/lookup/</link>
		<comments>http://whomwah.com/2009/04/07/lookup/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 11:53:14 +0000</pubDate>
		<dc:creator>Duncan</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[lookup]]></category>
		<category><![CDATA[OSX]]></category>

		<guid isPermaLink="false">http://whomwah.com/?p=1361</guid>
		<description><![CDATA[I work on a Mac at work, and it has always been a bit slow searching for other staff members in our global address book. Like other big organisations we have some directory services which we can use LDAP to interrogate. The seemingly standard way for apps to poll these services is asynchronously every second [...]]]></description>
			<content:encoded><![CDATA[<p>I work on a <a href="http://www.apple.com/mac/">Mac</a> at <a href="http://www.bbc.co.uk/">work</a>, and it has always been a bit slow searching for other staff members in our global address book. Like other big organisations we have some <a href="http://en.wikipedia.org/wiki/Directory_service">directory services</a> which we can use <a href="http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol">LDAP</a> to interrogate. The seemingly standard way for apps to poll these services is <a href="http://en.wikipedia.org/wiki/Asynchronous_I/O">asynchronously</a> every second or so, so that you&#8217;re getting results back quickly in the background. In reality this can be clunky if your network is slow, or the directory is very big.</p>
<p>I wanted something simpler, and a gui that gave me was suited to my work requirements. Lookup displays glance-able contact details straight away, letting you copy, paste and drag this data around. It also has simple shortcuts like double clicking the contact to start a new email to that person.</p>
<p>Lookup does not poll asynchronously, it does one request per search and just looks through some key attributes. It seems to work very well, and has been customised for my workplace, but is generic enough for someone to tweak it to suit their companies needs.</p>
<p><a href="http://www.flickr.com/photos/duncanponting/3420133723/"><img src="http://farm4.static.flickr.com/3302/3420133723_714683acc3.jpg?v=0" alt="Lookup" /></a></p>
<p>It wraps <a href="http://linux.die.net/man/1/ldapsearch">ldapsearch</a>, which is a command line app that comes free on your mac. When I say wraps, it&#8217;s not a complete wrapper, but wraps enough to create an app of this kind. Ldapsearch app did everything I wanted in search terms, and gave me a chance to use <a href="http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSTask_Class/index.html">NSTask</a> and <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSPipe_Class/index.html">NSPipe</a> which I know will be useful in the future.</p>
<p>You can get the <a href="http://github.com/whomwah/lookup/tree/master">source over at Github</a>. Why not try and tweak it to work for your company. You never know, just compiling it and updating the settings in the preferences menu may be enough.</p>
<p class="note">Just to be clear, this app does NOT give you access to the BBC address book, just incase you thought I&#8217;d gone mad.</p>
]]></content:encoded>
			<wfw:commentRss>http://whomwah.com/2009/04/07/lookup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TellyBox 1.4, Twitter, Scheduling .. plus the coolest icon</title>
		<link>http://whomwah.com/2009/03/22/tellybox-1_4/</link>
		<comments>http://whomwah.com/2009/03/22/tellybox-1_4/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 15:35:42 +0000</pubDate>
		<dc:creator>Duncan</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Applications]]></category>
		<category><![CDATA[BBC]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[tellybox]]></category>

		<guid isPermaLink="false">http://whomwah.com/?p=1283</guid>
		<description><![CDATA[[note] if you are updating and have the current app in your dock, you may need to remove it, and then re-add it again to get the new icon to appear straight away I&#8217;ve just released a new version of TellyBox, version 1.4. This version pulls in all the new features from sister app RadioAunty, [...]]]></description>
			<content:encoded><![CDATA[<p class="update">[<strong>note</strong>] if you are updating and have the current app in your dock, you may need to remove it, and then re-add it again to get the  new icon to appear straight away</p>
<p>I&#8217;ve just released a new version of <a href="http://whomwah.github.com/tellybox/">TellyBox</a>, version 1.4. This version pulls in all the<a href="http://whomwah.com/2009/03/14/radioaunty-feature-update-twitter-scheduling-and-much-more/"> new features from sister app RadioAunty</a>, plus a few news ones specific to TellyBox.</p>
<p>If you didn&#8217;t know, <a href="http://whomwah.github.com/tellybox">TellyBox</a> is a Mac app that allows you to watch live and catchup <a href="http://www.bbc.co.uk/tv/">BBC Television</a> (Uk users only I&#8217;m afraid). It uses the <a href="http://bbc.co.uk/iplayer/">BBC iPlayer</a> to actually display the telly, but wraps it all up into a native Mac application. </p>
<p><a href="http://www.flickr.com/photos/duncanponting/sets/72157614336016460/"><img src="http://farm4.static.flickr.com/3596/3372908443_537eb57e45.jpg?v=0" alt="TellyApp screenshot" /></a></p>
<p>Like I mentioned above, new features include <a href="http://twitter.com/">Twitter</a> support and scheduling as per <a href="http://whomwah.github.com/radioaunty/">RadioAunty</a>. I recommend <a href="http://whomwah.com/2009/03/14/radioaunty-feature-update-twitter-scheduling-and-much-more/">reading this post</a> to get more information on these. As well as them, the new features specific to TellyBox are:</p>
<ol>
<li>I have removed the default channel entry from the preferences. The app now just remembers what channel you last watched.</li>
<li>The close button, and zoom buttons (red and green) now work.</li>
<li>A brand new app icon (designed by <a href="http://boxblu.com/">David Wilson</a>)</li>
</ol>
<p>I&#8217;m really pleased with the icon. I know <a href="http://boxblu.com/?p=42">David spent a lot of time designing it</a>, and for a first application icon, I think it&#8217;s awesome. I also knew the effect I wanted. I really liked the idea of the icon being a mini telly showing you exactly what you are watching in the main screen. It seems <a href="http://normalkid.com/2008/05/09/application-icons-and-domain-names/">Mac icons can make or break an app</a>, so I&#8217;m hoping this one can only help.</p>
<p>It&#8217;s actually quite a simple effect to achieve. It&#8217;s just about building layers. I use <a href="http://www.cocoadev.com/index.pl?ScreenShotCode">CGWindowListCreateImage</a> to take a screen grab of what&#8217;s playing over time. When I have a new grab, I then construct the dock icon, using the grab at the bottom, then a version of the app icon with a transparent screen to give the glass effect, and finally the channel logo. If you minimize the app, or change windows using spaces, then the icon will change to the <a href="http://images.google.com/images?client=safari&#038;rls=en-us&#038;q=bbc+test+card&#038;oe=UTF-8&#038;um=1&#038;ie=UTF-8&#038;ei=f1TGSfjDPMaHtgfNyZHUCg&#038;sa=X&#038;oi=image_result_group&#038;resnum=1&#038;ct=title">BBC test card</a>.</p>
<p><a href="http://whomwah.github.com/tellybox/">Download TellyBox from the project page on Github</a>, or if you already have the app installed, then you should get a request to update automagically.</p>
]]></content:encoded>
			<wfw:commentRss>http://whomwah.com/2009/03/22/tellybox-1_4/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>RadioAunty feature update &#8211; twitter, scheduling and much more</title>
		<link>http://whomwah.com/2009/03/14/radioaunty-feature-update-twitter-scheduling-and-much-more/</link>
		<comments>http://whomwah.com/2009/03/14/radioaunty-feature-update-twitter-scheduling-and-much-more/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 19:50:40 +0000</pubDate>
		<dc:creator>Duncan</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[BBC]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[radioaunty]]></category>

		<guid isPermaLink="false">http://whomwah.com/?p=1239</guid>
		<description><![CDATA[In my on going Cocoa learning I have been working hard on updates for RadioAunty. ( If you didn&#8217;t know, RadioAunty is Mac app that allows you to listen to live and catchup BBC Radio ). This means the feature list is now quite compelling, so I decided to give and overview of the features [...]]]></description>
			<content:encoded><![CDATA[<p>In my on going <a href="http://developer.apple.com/cocoa/">Cocoa</a> learning I have been working hard on updates for <a href="http://whomwah.github.com/radioaunty/">RadioAunty</a>. ( If you didn&#8217;t know, RadioAunty is Mac app that allows you to listen to live and catchup BBC Radio ). This means the feature list is now quite compelling, so I decided to give and overview of the features to date.</p>
<p><strong>1. Select your Favourite Station</strong> &#8211; Choose from all the <a href="http://www.bbc.co.uk/radio/">BBC National radio stations</a>. You can listen to them in Normal RealPlayer or the much higher quality ACC streams. Make your decision via the preferences screen.</p>
<p><a href="http://www.flickr.com/photos/duncanponting/sets/72157615137746093/"><img src="http://farm4.static.flickr.com/3452/3351927033_7d2d56fcea.jpg?v=0" alt="RadioAunty select a Station" /></a></p>
<p><strong>2. Minimise the radio</strong> &#8211; I didn&#8217;t think people generally stare at the player whilst they are listening, so you can now minimise it like you can with <a href="http://www.apple.com/itunes">iTunes</a>, using ^ cmd Z or the window menu. You can also tweak the width whilst minimised. You will also see that the window title shows the current show playing. This updates along with the schedule as time goes on. More on this next.</p>
<p><a href="http://www.flickr.com/photos/duncanponting/sets/72157615137746093/"><img src="http://farm4.static.flickr.com/3454/3351927271_bd0ec71ca9.jpg?v=0" alt="RadioAunty minimized" /></a></p>
<p><strong>3. View the schedule</strong> &#8211; In the Schedule menu, you will see the day schedule for the station you are listening to (using data from <a href="http://bbc.co.uk/programmes">BBC programmes</a>). You will see a tick next to the show you are currently listening. You will also see that some shows are clickable. This is stuff you can listen to, that is available to catchup in <a href="http://www.bbc.co.uk/iplayer/">iPlayer</a>, it also displays how long left that show is available in iPlayer for. This schedule updates as you listen throughout the day. </p>
<p><img src="http://farm4.static.flickr.com/3434/3354268798_02081fdbf1.jpg?v=0" alt="RadioAunty schedule menu" /></p>
<p><strong>4. Twitter support and other preferences</strong> &#8211; The preferences window gives you the chance to change some of RadioAunty&#8217;s settings and turn on others. From the top, we have updates. Turning this on allows you to receive updates to the application when they become available. Next is default station. This allows you to choose a default station to open with (I think this may be removed next release, and the app will just remember what you last listened to. Next is audio quality. It&#8217;s best to stick to high quality, but those streams are only available in the UK, so if you are listening abroad you will have to choose normal quality. Finally <a href="http://twitter.com">Twitter</a> support. Opting in means that as you listen, details about what you are listening to will be sent to the <a href="http://twitter.com/radioandtvbot">@radioandtvbot</a> account on Twitter. If you supply your twitter username, this will be added to the tweet instead of the default, which is your computer login FullName. The screenshot below next shows you what gets sent.</p>
<p><a href="http://www.flickr.com/photos/duncanponting/sets/72157615137746093/"><img src="http://farm4.static.flickr.com/3651/3352752518_23810447a0.jpg?v=0" alt="RadioAunty twitter support" /></a><br />
<img src="http://farm4.static.flickr.com/3209/3353735857_4367bff3b6.jpg" alt="radioandtvbot" /></p>
<p><strong>5. A nice dynamic app icon</strong> &#8211; The wonderful Tim Broom made the current icon. The icon changes, showing the network you are currently listening to.</p>
<p><a href="http://www.flickr.com/photos/duncanponting/sets/72157615137746093/"><img src="http://farm4.static.flickr.com/3601/3351926135_fba2d2cf0d.jpg?v=0" alt="Nice Icon" /></a></p>
<p><strong>6. Growl support</strong> &#8211; If you use Growl, then RadioAunty will notify you when a show starts playing. If you choose the twitter support it will also notify you when this information is sent to twitter.</p>
<p><a href="http://www.flickr.com/photos/duncanponting/sets/72157615137746093/"><img src="http://farm4.static.flickr.com/3638/3351926335_acd4880bd6.jpg?v=0" alt="Growl Support" /></a></p>
<p>Next then. I&#8217;m going to be transferring the twitter and scheduling stuff over to <a href="http://whomwah.github.com/tellybox/">TellyBox</a> (A Mac app that allows you to watch live and catchup BBC Television). So watch out for the updates. Then I think <a href="http://www.last.fm/">lastfm</a> integration is on the cards. It&#8217;s be nice to scrobble what tracks you are listening to.</p>
]]></content:encoded>
			<wfw:commentRss>http://whomwah.com/2009/03/14/radioaunty-feature-update-twitter-scheduling-and-much-more/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Replicating Apples embossed text in a Cocoa App</title>
		<link>http://whomwah.com/2009/03/11/replicating-apples-embossed-text-in-a-cocoa-app/</link>
		<comments>http://whomwah.com/2009/03/11/replicating-apples-embossed-text-in-a-cocoa-app/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 11:22:04 +0000</pubDate>
		<dc:creator>Duncan</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[OSX]]></category>

		<guid isPermaLink="false">http://whomwah.com/?p=1203</guid>
		<description><![CDATA[[update] Thanks to the chaps below in the comments, my in-experience with cocoa is shown. This whole post could be replaced with this code: &#91;&#91;myTextField cell&#93; setBackgroundStyle:NSBackgroundStyleRaised&#93;; If you look at the text in the task or status bar on of a Mac app, you will see that the text has the appearance of being [...]]]></description>
			<content:encoded><![CDATA[<p class="update"><strong>[update]</strong> Thanks to the chaps below in the comments, my in-experience with cocoa is shown. This whole post could be replaced with this code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>myTextField cell<span style="color: #002200;">&#93;</span> setBackgroundStyle<span style="color: #002200;">:</span>NSBackgroundStyleRaised<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>If you look at the text in the task or status bar on of a Mac app, you will see that the text has the appearance of being embossed slightly. It is essentially a textField with some neat attributes associated with it.</p>
<p><a href="http://www.flickr.com/photos/duncanponting/3346662608/"><img src="http://farm4.static.flickr.com/3657/3346662608_9da98cf85b.jpg" alt="Apple embossed text" /></a></p>
<p>This effect does not come for free when you want to use your own <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextField_Class/Reference/Reference.html">NSTextField</a> somewhere else in your Apps window (actually, I think it does on the iPhone?). To recreate this effect is quite simple. You just need to create a <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSAttributedString_Class/Reference/Reference.html">NSAttibutedString</a> and associate the attributes below to it.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// Create the white shadow that sits behind the text</span>
<span style="color: #400080;">NSShadow</span> <span style="color: #002200;">*</span>shadow <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSShadow</span> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>shadow setShadowColor<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSColor</span> colorWithDeviceWhite<span style="color: #002200;">:</span>1.0 alpha<span style="color: #002200;">:</span>0.5<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>shadow setShadowOffset<span style="color: #002200;">:</span>NSMakeSize<span style="color: #002200;">&#40;</span>1.0, <span style="color: #002200;">-</span>1.1<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #11740a; font-style: italic;">// Create the attributes dictionary, you can change the font size</span>
<span style="color: #11740a; font-style: italic;">// to whatever is useful to you</span>
<span style="color: #400080;">NSMutableDictionary</span> <span style="color: #002200;">*</span>sAttribs <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSMutableDictionary</span> alloc<span style="color: #002200;">&#93;</span> initWithObjectsAndKeys<span style="color: #002200;">:</span>
    <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSFont</span> systemFontOfSize<span style="color: #002200;">:</span>11.0<span style="color: #002200;">&#93;</span>,NSFontAttributeName,
    shadow, NSShadowAttributeName,
    <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
<span style="color: #11740a; font-style: italic;">// The shadow object has been assigned to the dictionary, so release</span>
<span style="color: #002200;">&#91;</span>shadow release<span style="color: #002200;">&#93;</span>;
<span style="color: #11740a; font-style: italic;">// Create a new attributed string with your attributes dictionary attached</span>
<span style="color: #400080;">NSAttributedString</span> <span style="color: #002200;">*</span>s <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSAttributedString</span> alloc<span style="color: #002200;">&#93;</span> initWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;82 results found&quot;</span>
    attributes<span style="color: #002200;">:</span>sAttribs<span style="color: #002200;">&#93;</span>;
<span style="color: #11740a; font-style: italic;">// Set your text value</span>
<span style="color: #002200;">&#91;</span>myTextField setAttributedStringValue<span style="color: #002200;">:</span>s<span style="color: #002200;">&#93;</span>;
<span style="color: #11740a; font-style: italic;">// Clean up</span>
<span style="color: #002200;">&#91;</span>s release<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>I&#8217;m sure there are many other ways to achieve this effect, and I&#8217;d be interested in any easier versions, but this works for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://whomwah.com/2009/03/11/replicating-apples-embossed-text-in-a-cocoa-app/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Experiments in Cocoa #2 TellyBox</title>
		<link>http://whomwah.com/2009/02/23/tellybox/</link>
		<comments>http://whomwah.com/2009/02/23/tellybox/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 15:26:55 +0000</pubDate>
		<dc:creator>Duncan</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[BBC]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://whomwah.com/?p=1132</guid>
		<description><![CDATA[After my first foray into Cocoa development, which involved Radio, I decided to take what I had learnt and move into TV. Tellybox is the result. It&#8217;s a Cocoa desktop app that&#8217;s a wrapper for the BBC iPlayer live and catchup service for a day. I&#8217;m quite pleased with how it turned out. [BY THE [...]]]></description>
			<content:encoded><![CDATA[<p>After <a href="http://whomwah.com/2008/12/12/radioaunty/">my first foray into Cocoa development</a>, which involved <a href="http://www.bbc.co.uk/radio/">Radio</a>, I decided to take what I had learnt and move into <a href="http://www.bbc.co.uk/tv/">TV</a>. <a href="http://whomwah.github.com/tellybox/">Tellybox</a> is the result. It&#8217;s a <a href="http://developer.apple.com/cocoa/">Cocoa</a> desktop app that&#8217;s a wrapper for the <a href="http://www.bbc.co.uk/iplayer">BBC iPlayer</a> live and catchup service for a day. I&#8217;m quite pleased with how it turned out. </p>
<p class="note">[BY THE WAY] This is a personal learning project, and not affiliated with the BBC in any way. It (and I) only use publicly available information, in order to try and inspire people to just build cool stuff. If you think you could do better or have ideas in improving the app, please let me know. I&#8217;d love to hear from you.</p>
<p><a href="http://whomwah.github.com/tellybox/"><strong>Download TellyBox via it&#8217;s github project page</strong></a>.<br />
<img src="http://farm4.static.flickr.com/3536/3182285832_55c5b4fbc6.jpg?v=1231513818" alt="TellyBox - A Mac app that lets you watch the telly" /></p>
<p>Below I&#8217;ve briefly noted the various features, and what areas of Cocoa I had to learn to implement them. I &#8216;ve added a long list of resources at the bottom, which have and continue to, prove very useful when developing in Cocoa.</p>
<p><strong>1. Select your Favourite Station</strong> &#8211; You can select which channel you&#8217;d like to watch from the <em>Watch</em> menu. This involves reading in some <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Introduction/chapter_1_section_1.html">.plist</a> configuration data and displaying it in an <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/nsmenu_Class/index.html">NSMenu</a>. The menu is drawn with code, and once understood, meant building and manipulating all the other menus was a breeze.</p>
<p><img src="http://farm4.static.flickr.com/3583/3303848340_c1760e68ae.jpg?v=0" alt="Tellybox station selection" /></p>
<p><strong>2. Choose your viewing size</strong> &#8211; You can choose from a list of 5 sizes to view from. These sizes can be chosen from the <em>View</em> menu or the shortcuts 1-5. This sizes as well as the location of the display window are remembered when you quit the application. The resizing is using <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/index.html">NSWindows</a> <em>setFrame:display:animate:</em> to make it look pretty and is using <a href="http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/index.html">NSUserdefaults</a> to manage the remembering of the size and origin of the window.</p>
<p><img src="http://farm4.static.flickr.com/3607/3303019159_0c21c0da79.jpg" alt="Tellybox viewing sizes" /></p>
<p><strong>3. The day schedule</strong> &#8211; Here you get a list of what&#8217;s on the day you are watching, and what is available to watch again. It also marks where you are in that day. I still need to work on updating this schedules as currently it only loads when you first start viewing, so won&#8217;t change automatically over time. The schedule data comes from <a href="http://www.bbc.co.uk/programmes">BBC Programmes</a> via <a href="http://en.wikipedia.org/wiki/XML">XML</a> and is parsed using <a href="http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSXMLDocument_Class/index.html">NSXMLDocument</a>. It uses the same caching policy as the BBC site.</p>
<p><img src="http://farm4.static.flickr.com/3597/3303019117_882ba9b80c.jpg" alt="Tellybox schedule" /></p>
<p><strong>4. Growl Support</strong> &#8211; The app has <a href="http://growl.info">Growl</a> Notification support. If you have growl installed you will get notifications about what you&#8217;re watching. This was implemented with the <a href="http://growl.info/documentation/developer/implementing-growl.php?lang=cocoa">growl documentation</a> and uses the <a href="http://growl.info/documentation/developer/growlapplicationbridge.php">Growl Application Bridge</a>.</p>
<p><img src="http://farm4.static.flickr.com/3495/3303848750_d6884b7b17.jpg" alt="Growl Support" /></p>
<p><strong>5. Preferences</strong> &#8211; You can change a few preferences at the moment. One is the default Network that gets shown when you start the application. The other is whether you would like to receive automatic updates and how often you would like to check whether they&#8217;re available. The former uses <a href="http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/index.html">NSUserdefaults</a> and <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/">Cocoa Bindings</a>. The latter uses the popular and amazing <a href="http://sparkle.andymatuschak.org/">Sparkle update framework</a>.</p>
<p><img src="http://farm4.static.flickr.com/3579/3303848570_aa72cef637.jpg" alt="Tellybox - Preferences" /></p>
<p>Here&#8217;s a list of useful resources I&#8217;ve used to get to this point:</p>
<ul>
<li><a href="http://developer.apple.com/cocoa/">Cocoa</a></li>
<li><a href="http://cocoadevcentral.com/">Cocoa Central</a></li>
<li><a href="http://www.cocoadev.com/">Cocoa Dev</a></li>
<li><a href="http://lists.apple.com/archives/cocoa-dev">Cocoa-dev mailing list</a></li>
<li><a href="http://www.katidev.com/">Kati Dev</a></li>
<li><a href="http://www.amazon.co.uk/Cocoa-Programming-Mac-OS-X/dp/0321503619">Cocoa Programming for Mac OS X</a> essential!!</li>
<li><a href="http://www.amazon.co.uk/Programming-Objective-C-Stephen-Kochan/dp/0672325861">Programming in Objective C</a></li>
<li><a href="http://www.araelium.com/dmgcanvas/">DMG Canvas</a></li>
</ul>
<p>Finally a few things that don&#8217;t work so well. Well one at the moment really, and that&#8217;s guidance. I haven&#8217;t quite worked out how to get the iPlayer guidance stuff working in Tellybox, which means if the show you want to watch again has a guidance rating then the only way you can watch it, is to go to the web version. I&#8217;ll keep trying though.</p>
<p>I think that&#8217;s it. Hope you like it. I&#8217;m really enjoying Cocoa development at the moment and look forward to my next personal project.</p>
]]></content:encoded>
			<wfw:commentRss>http://whomwah.com/2009/02/23/tellybox/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Experiments in Cocoa #1 RadioAunty</title>
		<link>http://whomwah.com/2008/12/12/radioaunty/</link>
		<comments>http://whomwah.com/2008/12/12/radioaunty/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 21:47:05 +0000</pubDate>
		<dc:creator>Duncan</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Applications]]></category>
		<category><![CDATA[BBC]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[radioaunty]]></category>

		<guid isPermaLink="false">http://whomwah.com/?p=826</guid>
		<description><![CDATA[[UPDATE] I&#8217;ve updated the app to now use the new higher quality live streams. Yay, no more RealPlayer for the majority. I&#8217;ve seem to have spent a lot of time reading about Cocoa without actually building anything of substance. So to put a change to that I have built RadioAunty. 1. RadioAunty &#8211; This is [...]]]></description>
			<content:encoded><![CDATA[<p class="update">[UPDATE] I&#8217;ve updated the app to now use the <a href="http://www.bbc.co.uk/blogs/bbcinternet/2009/02/better_audio_for_bbc_radio_onl.html">new higher quality live streams</a>. Yay, no more RealPlayer for the majority.</p>
<p>I&#8217;ve seem to have spent a lot of time reading about <a href="http://developer.apple.com/cocoa/">Cocoa</a> without actually building anything of substance. So to put a change to that I have built <a href="http://whomwah.github.com/radioaunty/">RadioAunty</a>.</p>
<p>1. <a href="http://whomwah.github.com/radioaunty/">RadioAunty</a> &#8211; This is a Cocoa Application that lets you listen to the radio, <a href="http://www.bbc.co.uk/radio/">BBC radio</a>, on your desktop. You can view the current schedule and select listen again shows, as well as simply changing the station via the menu bar and via the Dock. You can also set preferences to decide which should be your default Station to start with, and whether you would like to receive updates to the application when they are available (very important). If you have <a href="http://www.bbc.co.uk/iplayer/radio/">listened to BBC radio</a> via <a href="http://www.apple.com/safari/">Safari</a>, then RadioAunty should work just fine for you.</p>
<p><a href="http://whomwah.github.com/radioaunty/">Download RadioAunty from it&#8217;s project site</a></p>
<p><img src="http://farm4.static.flickr.com/3286/3103478230_d9e063d34a.jpg?v=1231598066" alt="RadioAunty" /></p>
<p>There are now many <a href="http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/chapter_2_section_5.html">*.frameworks</a> that come as part of the <a href="http://developer.apple.com/Tools/">Apple Developer Tools</a> and  I found it pretty daunting to start with. So to make life easier for myself, I decided to start small and build bigger as I go along. This is why I started with the simple idea of RadioAunty. Oh and it&#8217;s <a href="http://www.apple.com/macosx/">Leopard</a> only because it seemed silly to have to learn old ways of doing things as well as new.</p>
<p>RadioAunty is at a high level not that complex. It basically embeds an already existing webpage into a desktop app. It seemed like an ideal starting point. Once I had got that working (Thanks <a href="http://www.apple.com/">Apple</a>, it takes about 3 lines of code!), the next thing was to make use of other classes and functionality to actually learn something. The app as it stands uses only uses these Cocoa classes (I&#8217;ve left the boring ones out):</p>
<ul>
<li><a href="http://developer.apple.com/documentation/Cocoa/Reference/WebKit/Classes/WebView_Class/index.html">WebView</a></li>
<li><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSMenu_Class/Reference/Reference.html">NSMenu</a></li>
<li><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSProgressIndicator_Class/Reference/Reference.html">NSProgressIndicator</a></li>
<li><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindowController_Class/Reference/Reference.html">NSWindowController</a></li>
<li><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSPropertyListSerialization_Class/Reference/Reference.html">NSPropertyListSerialization</a></li>
<li><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html">NSUserDefaults</a></li>
<li><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/Reference/Reference.html">NSBundle</a></li>
<li>SUUpdater (Part of <a href="http://sparkle.andymatuschak.org/">the wonderful Sparkle Framework</a>)</li>
</ul>
<p>I&#8217;ve used @property quite a lot (properties are a bit like <a href="http://ruby-lang.org/">Ruby</a> <a href="http://www.ruby-doc.org/docs/UsersGuide/rg/accessors.html">:attr_accessor</a>) to automagically create getter and setters. I have also use key-value bindings, which once I understood them were amazing, and allow you to chop huge chunks of code from your source. I use a stations.plist to store the radio station data, but hope to pull that from the web in the future, meaning that it could play any radio station and not just the BBC&#8217;s. I also use delegation a lot whenever I can.</p>
<p>As I only started the app on Tuesday, I&#8217;ll continue making it more polished, that and I have a few other ideas, but I wanted to get something out for people to use as quickly as possible, so first main thing to add (apart from the radio) was auto-updating. This is taken care of by <a href="http://sparkle.andymatuschak.org/files/Sparkle%201.5b6.zip">Sparkle 1.5b6</a>.</p>
<p><a href="http://sparkle.andymatuschak.org/">Sparkle</a> was super simple to implement. Their <a href="http://sparkle.andymatuschak.org/documentation">wiki documentation</a> worked great, and I was amazed that something I always think is cool, and take for granted was so smooth to implement in this application. If you&#8217;re building OSX applications then this should surely be a must.</p>
<p>I have a few other projects in the pipeline, that incorporate more frameworks for me to learn, so stay posted. I&#8217;m progressing well with is an app called LeaveFrom, that does what is says on the tin really. It uses <a href="http://developer.apple.com/macosx/coredata.html">Core-Data</a> which again had a bit of a learning curve, but I&#8217;m getting on ok. Can my old brain take all this new fun information.</p>
]]></content:encoded>
			<wfw:commentRss>http://whomwah.com/2008/12/12/radioaunty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

