<?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>mattsoftware</title>
	<atom:link href="http://www.mattsoftware.com/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mattsoftware.com/wordpress</link>
	<description>development services, targetting wordpress, linux and software deveopment</description>
	<lastBuildDate>Wed, 21 Apr 2010 11:36:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Learning programming?</title>
		<link>http://www.mattsoftware.com/wordpress/2010/04/21/learning-programming/</link>
		<comments>http://www.mattsoftware.com/wordpress/2010/04/21/learning-programming/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 11:36:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.mattsoftware.com/wordpress/?p=121</guid>
		<description><![CDATA[I&#8217;ve started a google document that outlines how to write a software program. It&#8217;s not very useful at the moment but I intend on padding it out with great stuff soon.
How To Write A Program From Scratch (Hints and Tips)
Enjoy  
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started a google document that outlines how to write a software program. It&#8217;s not very useful at the moment but I intend on padding it out with great stuff soon.</p>
<p><a href="http://docs.google.com/View?id=df6p2cp8_186ctkvgqft">How To Write A Program From Scratch (Hints and Tips)</a></p>
<p>Enjoy <img src='http://www.mattsoftware.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattsoftware.com/wordpress/2010/04/21/learning-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone Development and Code Reuse</title>
		<link>http://www.mattsoftware.com/wordpress/2010/01/09/iphone-development-and-code-reuse/</link>
		<comments>http://www.mattsoftware.com/wordpress/2010/01/09/iphone-development-and-code-reuse/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 10:55:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://www.mattsoftware.com/wordpress/?p=90</guid>
		<description><![CDATA[Software development is a passion of mine. My honours thesis was on Software Reuse, something that all software developers should strive to do. During me research I was led down the path of many different technologies to do with software reuse. One of those particular technologies was Software Libraries.
My pain today has been trying to [...]]]></description>
			<content:encoded><![CDATA[<p>Software development is a passion of mine. My honours thesis was on Software Reuse, something that all software developers should strive to do. During me research I was led down the path of many different technologies to do with software reuse. One of those particular technologies was Software Libraries.</p>
<p>My pain today has been trying to work out a software reuse procedure for iPhone development. In some ways I have been very unsuccessful, but un the end I believe I have worked out a reasonable way to do it. Note that I have googled many different searches and have usually come up with no help. There were a few good tutorials which have been useful, and I have derived my procedure based on these posts&#8230;</p>
<ul>
<li><a href="http://www.amateurinmotion.com/articles/2009/02/08/creating-a-static-library-for-iphone.html">Creating a Static Library for iPhone</a></li>
<li><a href="http://www.amateurinmotion.com/articles/2009/02/08/creating-a-static-library-for-iphone.html"></a><a href="http://blog.stormyprods.com/2008/11/using-static-libraries-with-iphone-sdk.html">Building static libraries with the iPhone SDK</a></li>
<li><a href="http://blog.stormyprods.com/2008/11/using-static-libraries-with-iphone-sdk.html"></a><a href="http://www.clintharris.net/2009/iphone-app-shared-libraries/">Easy, Modular Code Sharing  Across iPhone Apps: Static Libraries and Cross-Project References</a></li>
<li><a href="http://www.clintharris.net/2009/iphone-app-shared-libraries/"></a><a href="http://dev.byteclub.com/blog/1-iphone-sdk/48-how-to-almost-create-your-own-iphone-os-framework">How to (almost) create your own iPhone OS framework</a></li>
</ul>
<h2>Library</h2>
<h3>Step One: Create the library project</h3>
<p>For simplicity I will keep out the SVN related stuff. I am in the process of creating my post on Subversion integration with my projects, stay tuned.</p>
<p>Jump into xcode and create a new window based application, call it MyLibrary for example. This is actually useful as we can use the project to test our library code as well.</p>
<h3 style="font-size: 1.17em;">Step Two: Create the static library target</h3>
<p>Right click on the &#8220;Targets&#8221; node in the xcode project list. Select &#8220;add -&gt; New Target&#8230;&#8221;.</p>
<p>Choose the &#8220;Cocoa Touch&#8221; option on the right, and the &#8220;Static Library&#8221; icon in the left pane. Call it &#8220;libMyLibrary&#8221;. When the information screen comes up, change the &#8220;Product Name&#8221; to &#8220;MyLibrary&#8221;. (note this can be changed later by right clicking the target and choosing &#8220;get info&#8221;.)</p>
<h3>Step Three: Create some classes</h3>
<p>To test the library lets create a new class (in the Classes directory). Select the NSObject as the super class, call it &#8220;MyClass.m&#8221;, and add it to the new target (by clicking the check box next to the &#8220;libMyLibrary&#8221; target).</p>
<p>Add some simple code, first the header&#8230;</p>
<pre style="padding-left: 30px;">#import &lt;Foundation/Foundation.h&gt;
@interface MyClass : NSObject
{
}
+(void)hello;
@end</pre>
<pre><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;">And of course the implementation...</span></pre>
<pre style="padding-left: 30px;">#import "MyClass.h"
@implementation MyClass
+(void)hello
{
<span style="white-space: pre;">	</span>NSLog(@"Hello");
}
@end</pre>
<p>Save the files.</p>
<h3>Step Four: export the header as public</h3>
<p>In the &#8220;Targets&#8221; node in the right hand list, click the &#8220;libMyLibrary&#8221; node. The filelist will now have your MyClass.h and MyClass.m files. You need to change the &#8220;project&#8221; role next to the MyClass.h file to say &#8220;public&#8221;.</p>
<h3>Step Five: done with the library</h3>
<p>For the moment&#8230;</p>
<h2>Client</h2>
<h3>Step One: Create the project</h3>
<p>Call it &#8220;MyApp&#8221;. Any more need to be said?</p>
<h3>Step Two: Create a reference in the application to your library</h3>
<p>This is a slightly tricky step. Basically all you need to do is in your library project there is a list on the right hand side showing up the top your library (MyLibrary) and nodes beneth it with classes, resources etc. Click and drag the &#8220;MyLibrary&#8221; icon (right up the top) over to your new project, drop it at the same place (where it says MyApp). Make sure the &#8220;copy&#8221; checkbox is not checked (you do not want to copy it, you just want it referenced). Click Add.</p>
<p>You may notice that underneath the reference you just created there are two items, MyLibrary.app and libMyLibrary.a.</p>
<ul>
<li>MyLibrary.app is your actual app. You can safely ignore this for the imported project</li>
<li>libMyLibrary.a is the static library.</li>
</ul>
<p>You will notice these correspond to the targets in the MyLibrary app.</p>
<h3>Step Three: Tell your code where the header files are (this is for code completion to work)</h3>
<ul>
<li>Right click the &#8220;MyApp&#8221; icon at the top of that right hand list, go down to &#8220;Get Info&#8221;.</li>
<li>Click the &#8220;Build&#8221; section. This will show all the build settings defined for your project. The list is very long, so we&#8217;ll use the search box to narrow down what we see. Type in &#8220;header search&#8221; in the search box.</li>
<li>The field we are looking to change is the &#8220;User Header Search Paths&#8221; option. Double click the blank area next to it (which will enable you to edit the paths).</li>
<li>Click the [+] button to add another path</li>
<li>Double click the new path blank area to type in the path you want</li>
</ul>
<p>This is where you need to reference the actual path of your &#8220;MyLibrary&#8221; project. In my case I have used the same directory for both the MyApp and MyLibrary projects, so I can simply type into this field&#8230;</p>
<p>../MyLibrary/</p>
<p>Out of interest I also select the Recursive checkbox as well.</p>
<ul>
<li>Close that window</li>
</ul>
<h3>Step Four: Start Coding</h3>
<p>Open up the &#8220;MyAppAppDelgate.m&#8221; file. If you have added the header include path correctly you should be able to add the following at the top of the file (just under the #import &#8220;MyAppAppDelegate.h&#8221; statement)&#8230;</p>
<p>#import &#8220;MyC</p>
<p>&#8230; and you should now see the auto completion kick in and see the remainder of the line&#8230;</p>
<p>#import &#8220;MyClass.h</p>
<p>&#8230; Of course you should now complete the line (#import &#8220;MyClass.h&#8221;)</p>
<p>Next you can add the following line of code in the applicationDidFinishLoading function (which is created for you). Modify it to say this&#8230;</p>
<pre style="padding-left: 30px;">- (void)applicationDidFinishLaunching:(UIApplication *)application 
{    
    <strong>[MyClass hello];</strong>
    // Override point for customization after application launch
    [window makeKeyAndVisible];
}</pre>
<p>Build and run. You should see &#8220;hello&#8221; on the console. That was from our original library code.</p>
<h3>Step Five: Add a linker reference and build dependancy on the library</h3>
<p>For those that are following step by step and are a little savy may notice that&#8230;</p>
<p>a) the items under the MyLibrary.xcodeproj (which are the targets for the MyLibrary project) are both red. And&#8230;</p>
<p>b) we haven&#8217;t built the library yet.</p>
<p>This was done on purpose as we want the library to be built as a dependency on the current project. Of course you may not want this as part of your build process, but I like to keep my code sane, so rebuilding often means I need to check and fix bugs often. Not a bad thing. But before we add this dependancy lets tell the linker to link against our static library, then we can add the build dependency.</p>
<ul>
<li>open up the &#8220;Targets&#8221; node in the list in xcode</li>
<li>You will see the Link Binary with Libraries node.</li>
<li>Drag the &#8220;libMyLibrary.a&#8221; from our imported project into this node.</li>
</ul>
<p>Now we are ready to add the build dependency.</p>
<ul>
<li>Right-click the &#8220;Targets -&gt; My App&#8221; node and go down to &#8220;Get Info&#8221;</li>
<li>Click on the General button, up the top of that screen you should see the option &#8220;Direct Dependencies&#8221; box.</li>
<li>Click the [+] button</li>
<li>Click the libMyLibrary target</li>
<li>Click the &#8220;Add Target&#8221; button</li>
<li>Close the window.</li>
</ul>
<h3>Step Six: Build and run the project</h3>
<p>Try building the project now.</p>
<p>The simulator should run, and the words &#8220;Hello&#8221; should be written in the debug console. Success <img src='http://www.mattsoftware.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You will also notice the &#8220;libMyLibrary.a&#8221; target in our imported project is now black &#8211; hence its been built.</p>
<h2>Changes to the Library</h2>
<p>You can now add another method to your MyClass, get it to do something else. Save it.</p>
<p>Head back to your client project, use the new method, build and run. The library should now be rebuilt and the new method available immediately for use.</p>
<h2>Conclusion</h2>
<p>This is about the easiest method I have found through my research today to create a library of reusable code for the iPhone. Why I am unable to create a framework to be used in an iPhone app is a bit of a loss to me (thank you Apple for making this so hard). In my opinion, to foster reuse of code, the ability to create a framework and add it to a project far outweighs the eleven steps outlined above. <strong>C&#8217;mon Apple.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattsoftware.com/wordpress/2010/01/09/iphone-development-and-code-reuse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wheres the page up, Mr MacBook?</title>
		<link>http://www.mattsoftware.com/wordpress/2010/01/04/wheres-the-page-up-mr-macbook/</link>
		<comments>http://www.mattsoftware.com/wordpress/2010/01/04/wheres-the-page-up-mr-macbook/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 02:20:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.mattsoftware.com/wordpress/?p=82</guid>
		<description><![CDATA[Today&#8217;s post will be short &#8211; I promise!
Well. If anything has annoyed me about my new MacBook is the lack of page up and page down keys. There are substitutes for a few applications, but I find myself wondering how to navigate by pages in most of my work so far.
Fn &#8211; up/down arrow keys
This [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s post will be short &#8211; I promise!</p>
<p>Well. If anything has annoyed me about my new MacBook is the lack of page up and page down keys. There are substitutes for a few applications, but I find myself wondering how to navigate by pages in most of my work so far.</p>
<h2>Fn &#8211; up/down arrow keys</h2>
<p>This one appears to me to be the most common one. However it has some pitfalls&#8230;</p>
<p>Take Thunderbird mail for instance. This keyboard shortcut does nothing (really, I want the selected message to be the one a page higher, so I can navigate my sometimes overly full inbox, with ease). As another instance, take editing an email in Thunderbird mail. This shortcut scrolls the view up by a page, but thats not what I want &#8211; I want to move my cursor up by a page. Highly annoying.</p>
<p>So I thought it may just be that Thunderbird did not correctly map these key strokes, but after opening the standard TextEdit application that comes with the OS, the same happens, the view is scrolled, but the cursor stays where it is. If anyone knows a way to move the cursor up the page with the keyboard (without hitting the up arrow 40 times), I&#8217;de greatly appreciate it.</p>
<h3>But wait, Google Docs to the rescue, or is it?</h3>
<p>So then of course I tried a few other applications, the first one being Google Docs Spreadsheet. I tried page up and down, and by golly it worked. This is fantastic. I hit fn-up and the selected cell at the bottom of the page becomes unselected, and the unselected cell at the top of the page gains focus. Awesome!</p>
<p>But of course trying it in wordprocessor just happens the same way.</p>
<h3>Conclusion&#8230;</h3>
<p>Page up on the mac does not work like page up on linux/windows. This is actually confirmed by this post&#8230; <a href="http://www.macosxhints.com/article.php?story=20091125085551262">Move the cursor during Page Up, Page Down scrolling</a> &#8230; in case anyone is interested. Apparently you *can* get it to work in some applications, but not all.</p>
<h3>PS: Vim seems to have its own mapping</h3>
<p>There are probably not a lot of Mac users out there using VIM, but as I am from a Linux background, and a programmer, I simply love the power and simplicity with VIM. (For those who do not know, VIM is a console based text editor, everything can be done on the keyboard to navigate and edit the document). But of course I do a lot of navigating large source files using pageup and pagedown keys. I found this trick that helps me do that&#8230;</p>
<p>ctrl-f and ctrl-b</p>
<p>I can only guess, but I think my guess is very good&#8230; If you want to page down (or move forward in the document) try ctrl-f, and of course ctrl-b for moving backward in the document. Its not exactly intuitive, and a little awkward for the muscle memory to adjust to, but seems as though when I&#8217;m paging up I usually hit it about 10 times (until I find the place I want to stop, or I could simply be reading the document quickly) its not too much of an issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattsoftware.com/wordpress/2010/01/04/wheres-the-page-up-mr-macbook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No Garbage Collection for iPhone, HUH?</title>
		<link>http://www.mattsoftware.com/wordpress/2009/12/19/no-garbage-collection-for-iphone-huh/</link>
		<comments>http://www.mattsoftware.com/wordpress/2009/12/19/no-garbage-collection-for-iphone-huh/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 22:44:21 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.mattsoftware.com/wordpress/?p=72</guid>
		<description><![CDATA[So I&#8217;m continuing with my learning of Objective-C, and everything was looking fantastic. The syntax is a little odd, but easy to learn. The message passing philosophy is not what I&#8217;m used to, but I like it. Even an overview of how the technology works internally has me thinking how nice Objective-C is&#8230;
Enter Garbage Collection.
I [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;m continuing with my learning of Objective-C, and everything was looking fantastic. The syntax is a little odd, but easy to learn. The message passing philosophy is not what I&#8217;m used to, but I like it. Even an overview of how the technology works internally has me thinking how nice Objective-C is&#8230;</p>
<h3 style="font-size: 1.17em;">Enter Garbage Collection.</h3>
<p>I have had very little to do with cleaning up after myself in the past with software and memory allocation. Of course at Uni when we used C/C++ then every time we allocated memory we needed to deallocate the memory when we were finished. But from memory we were only really marked on the topics like linked-lists and stacks, where the only real way to create such structures is to allocate memory and fill it up. That was later in the course. Soon after that I had moved universities and entered into Java, a garbage collector is included as part of the virtual machine, and was never even spoke about, let alone concentrated on as a topic.</p>
<p>All the languages I use currently either a) have a garbage collector, or b) lifetime of the program is too short to worry about garbage collection.</p>
<h3 style="font-size: 1.17em;">Why is picking up garbage useful?</h3>
<p>Essentially for software to be useful it has to store data. To store data it needs to be put in the memory on your computer, using virtual ones and zeros. Its almost like a storeroom or a warehouse. To store a box you need somewhere to put it. You may have a glance around the storeroom, find somewhere that the box will fit (or course different sized boxes require different sized storage spaces), then you go and put the box there. This is pretty simple for small storerooms, but if you are doing this in a warehouse then you really do need some way of finding that box again in the future. You might mark the box with what it is (useful thing to do anyway) but if you have millions of boxes then you need another way of finding that box later. You might create an index card (if you can forget about computers/barcoding/gps/rfid/etc) that has the contents of the box, the owner of the box and the location of the box. It might be in isle 35, 14 meters down on the left, 4 boxes high. That index card gets stored alphabetically so you can find the card quickly, and then you know where the box is in the storeroom.</p>
<p>Computer memory is almost exactly the same. When you allocate a piece of memory, the &#8220;memory allocation&#8221; code works out where it will be stored, based on the size of the memory you wish to allocate. It will mark that space as being allocated (so it doesn&#8217;t accidentally store something else in there) and return a pointer to that space back to the code that wanted the space. So far so good. When you are finished with that memory you then need to tell the &#8220;memory allocation&#8221; code to release that memory (remember that the memory allocation code is remembering to not give that memory to anything else).</p>
<p>With languages like Java, this is done by setting your object to Null. Note this does not deallocate the memory there and then. Periodically the &#8220;garbage collection&#8221; code will as the &#8220;memory allocation&#8221; code for a list of all the objects that it has allocated, and see if any of them are being used. It goes through the list, one by one, and see how many pointers are pointing to the memory. If it finds at least one pointer, then that memory is still being used and then moves onto the next piece of allocated memory. When it finds allocated memory that has no pointers pointing to it, then it will ask the &#8220;memory allocation&#8221; code to deallocate that memory. This is done periodically, and is a little overkill for processing power than some small devices can handle. Remember on phones like the iPhone that extra processing power means lower battery life.</p>
<p>Just a side note to say that the Google Android powered phones do have garbage collection, where as the iPhone doesn&#8217;t. Although the whole battery life argument makes sense, I still think garbage collection is an important programmers tool, especially as you have the option of turning it on or off using Objective-C and the COCOA framework.</p>
<h3 style="font-size: 1.17em;">Why not pick up after yourself?</h3>
<p>Programmers are lazy. Thats why they program. If programmers didn&#8217;t mind doing the same thing over and over again, then they would just do it. The fact that doing things over and over is boring enlightens a programmer to code a solution so next time they have to do it, click a button or type a command and let the computer do it for you.</p>
<p>Unfortunately programming isn&#8217;t easy. Well, it is, but the more complex a problem, the more complex the solution becomes. From the early days when programmers used <a title="punch cards" href="http://en.wikipedia.org/wiki/Punch_cards" target="_blank">puch cards</a> to do their programming, designing a solution for even a simple problem was a complicated process. Until of course someone created a simpler process that enabled input to the computer via a keyboard, rather than puch cards (note I&#8217;m not an historian, I&#8217;ve probably missed a few steps here). However entering ones and zeros into a computer was not only mundain but practically impossible to memorise the sequence required for each command, and then of course do the decimal to binary conversion required to get numbers into the machine. A typical command (made up, dont try this at home, it wont work) might be to add two numbers together. So you need a command to add (00010001) and then the two numbers, say 5 (0000101) and 11 (00001011). The machine (made up machine again) might expect the sequence to be &#8220;command arg1 arg2&#8243; in which the programmer would need to enter (via keyboard or puchcard) the sequence&#8230;</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">000100010000010100001011</pre>
<p>Just to add the numbers 5 and 11 together. Of course there were 10&#8217;s or 100&#8217;s of commands. Practically impossible to get things done without manuals. Enter Assembly. Assembly was a program that took a sequence of charaters and converted them to the ones and zeros required for computation. So a programmer could write, for instance&#8230;</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">add 5 10</pre>
<p>and the exact same sequence of ones and zeros above would be created. Neat! But of course the programmers needed to do things like jumps and jump-if&#8217;s and all nasty stuff that could potentiall lead to bad things happening (which by the way still happens!). So higher level languages evolved to do loops and jumps and all the nice things to help make programming easier and more reliable. Paradigms popped up like Object-Orientation, Aspect Programming and the likes to help solve problems that lower level langauges introduced, like memory leaks.</p>
<p>Memory leaks happen when you have a long running software process that allocates memory, but does not deallocate it. Example. Say you are writing a program to generate lotto numbers for people. Say it is a server, so it runs constantly. When a request comes in you need to generate 8 random numbers and provide that to the person making the request. First you allocate memory for 8 numbers, fill the memory with the random numbers, send the number to the person makeing the request, job done. Or is it? You havn&#8217;t told the memory manager to free up that memory. The next request comes in, you allocate more memory (note now you have memory allocated for 16 numbers now!). Each request will come in, filling up more memory until finally it will exhaust your computer memory and the server will crash. Of course you could reuse that memory each time, but what happens when two requests come in quickly? One of the results will be tainted with the other requests results. Not that its that much of an issue with random numbers, but if it was more critical information then you would have a disaster on hand.</p>
<p>Allocating and deallocating memory is a bit of a hassle. In my opinion higher level languages should work out when you no longer are using an object, and deallocate that for you as required. This is why I quite like Python as a programming language. Python takes out the bits that computers can do for you, while the programmer is only interested in telling the computer what needs to be done. Whilst I like Objective-C, I do like the Python language better. Its cleaner (no need for header files and implementation files), the syntax is minimalist (why do i need semi colons at the end of lines, and end  of line tells me its the end of line, also, for cleaner code its best to put each statement on a different line), I have control over my objects (if I need to add a method at runtime, no problem, if i need to use another classes method on my own object, no problem) and last and probably least, I&#8217;m not locked into what i call my object (this?, self?). Okay, that last one is not really that important, but I find it very neat. Note of course all this is my opinion only, and there are a ton of pro&#8217;s and con&#8217;s for each language.</p>
<p>So back to garbage collection. The COCOA framework for Mac OS has garbage collection built in. Which is really neat. Unfortunately the iPhone has been stripped of this capability for performance reasons. So we need to pick up after ourselves if we write for the iPhone. I prefer to write for the lowest common denominator, so I&#8217;m going to try to code my Objective-C objects with my own cleanup in mind. Note there are a few different ways to do this, I&#8217;m going to describe one of them. One advantage to doing it this way is that if garbage collection is enabled, then the memory management code is ignored, so I do not need to write checks constantly to see if the garbage collection mechanism is turned on or not, I can just write the code, allocating and deallocating memory as required and let the compiler work out what to ignore and what to keep. Using the method below is also compatible with older Mac OS systems that do not have garbage collection, as well as the iPhone which also does not.</p>
<p>NSObject (which all COCOA Framework objects inherit from) has a mechanism built in which we can use to manually count references to the object. After memory for an object has been allocated and the object initialised, the releaseCount member gets set to 1. We can then ask that number be increased [obj retain], or decreased [obj release] as we need to. Instead of deallocating an object by calling [obj dealloc] the object itself will call it based on the release call. If releasing an object has no more interest in the object (releaseCount is 0) then the object will deallocate itself. This is pretty neat.</p>
<h3 style="font-size: 1.17em;">Enough, lets see some code&#8230;</h3>
<p>As I am generally only new at garbage collection, I am going to try and create some conventions that will help me remember to release memory when required. Lets start with a simple example&#8230;</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding-left: 30px;">NSCalendarDate *now = [[NSCalendarDate alloc] init]; /// @todo release
// do something with now
now = nil;</pre>
<p>Note that this is enough for the garbage collector to kick in and clean up for us. But unfortunately, its not enough for no garbage collection, the *now pointer no longer points to the allocated memory, but that memory is not deallocated yet. We have a problem as now we no longer know where that memory is (we have lost our pointer to it). Note also my todo comment, this is my way of reminding me I have to release that memory.</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding-left: 30px;">NSCalendarDate *now = [[NSCalendarDate alloc] init]; /// @done release
// do something with now
[now release]; // release before we loose the pointer to it
now = nil;</pre>
</pre>
<p>So the init message increased the count to 1, and the release message decreases it to 0 and the object is deallocated. Simple!</p>
<p>Object variables are slightly different, as you may not get a chance to deallocate them specifically. You must handle these when your object is being deallocated&#8230;</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding-left: 30px;">@interface MyClass : NSObject
{
     NSCalendarDate *now;
}
@end
@implementation MyClass
- (void) init
{
     [super init];
     now = [[NSCalendarDate alloc] init]; /// @todo release
}
@end</pre>
<p>So here we have a very very basic class which as a NSCalendarDate allocated. We need to now override the dealloc method to release the NSCalendarDate object&#8230;</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding-left: 30px;">- (void) dealloc
{
     [now release]; now = nil;
     [super dealloc]; // dont forget to trickle up the inheritance tree
}</pre>
<p>One other difficulty that has popped up is when you are returning an object from a method call.</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding-left: 30px;">- (NSString *) description
{
     NSString *result;
     result = [[NSString alloc] initWithFormat : @"say something useful here"]; /// @todo release
     return result;
}</pre>
<p>As you can see the problem here is that I have allocated memory for an object (release) but I have not deallocated it. Its unreasonable for the caller to clean up for us. We also cannot call release in the method as we will no longer have an object to return. For this we have the autorelease message.</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding-left: 30px;">- (NSString *) description
{
     NSString *result;
     result = [[NSString alloc] initWithFormat : @"say something useful here"]; /// @done release
     [result autorelease];
     return result;
}</pre>
<p>What we have done here is added our result object to the autorelease pool. When the event loop is finished the object will be sent a release and cleaned up if necessary. If the calling code wants to keep this object for its own use, then it will need to send the object a retain to keep it from being deallocated at the end of the event loop. That code could look like this&#8230;</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding-left: 30px;">NSString *desc;
desc = [myObj description]; // note this is in the autorelease pool
[desc retain]; // hold onto it until i want to remove it
// later on, possibly in dealloc or somewhere else.
[desc release];</pre>
<p>Note that objects created by alloc, new, copy or mutableCopy have a retain count of 1, and are NOT in the autorelease pool. You will need to release these objects when they are not needed anymore.</p>
<p>Note also that if you get an object using any other method, then you should assume it is in the autorelease pool.</p>
<p>Note that if you do return objects then dont forget to put them in the autorelease pool.</p>
<p>The one last example I want to show you is using setter methods on your object. These are methods that allow you to set a data member. However you really do need to release the existing value, before you assign a new object to it. For this we use &#8220;retain, release&#8221;.</p>
<pre style="padding-left: 30px; ">- (void) setNow : (NSCalendarDate *) newNow
{
     [newNow retain]; // remember the local code will probably release their copy if they want to, so we need to declare our interest in it.
     [now release]; // not interested in the old copy anymore
     now = newNow;
}</pre>
<p>You could of course release the old object, then retain the new one, however there is a corner case where this is bad. If the message is to set the value with the value thats already there (which of course is a useless call, but certainly possible) then you would actually be releasing the value you have, possibly deallocating it at the same time, which would also deallocate the actual value thats being passed in, causing nil to be set to the variable, which is NOT what we wanted.</p>
<h3>Final thoughts</h3>
<p>Note that there are objects that will increase the retain count automatically, like NSArray for example. When you add an object to an array, you send the addObject message to the array, passing the object you wish to add. That code will retain the object (as it now has an interest in it). If your code is no longer interested in the object, you will need to release it still. When you are finished with the array, you send it the release message, and if the releaseCount is down to zero then the array will send release to every object it has in store before it is deallocated.</p>
<p>I guess the moral to the story is you have to clean up objects locally, in your own code. If you create objects you must release them. If you get objects from somewhere else assume they are going to disappear. If you want those objects to hang around you must retain them, and remember to release them later.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattsoftware.com/wordpress/2009/12/19/no-garbage-collection-for-iphone-huh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Object Orientation, Objective-C Primer/Basics</title>
		<link>http://www.mattsoftware.com/wordpress/2009/12/12/object-orientation-objective-c-primerbasics/</link>
		<comments>http://www.mattsoftware.com/wordpress/2009/12/12/object-orientation-objective-c-primerbasics/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 10:23:01 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://www.mattsoftware.com/wordpress/?p=67</guid>
		<description><![CDATA[Not that I am in any way an expert in Objective-C, but from the last week of looking at the language I think it would be beneficial to throw some thoughts I have on the language, and provide some technical information I have come across. My main reason for purchasing a Mac was to do iPhone [...]]]></description>
			<content:encoded><![CDATA[<p>Not that I am in any way an expert in Objective-C, but from the last week of looking at the language I think it would be beneficial to throw some thoughts I have on the language, and provide some technical information I have come across. My main reason for purchasing a Mac was to do iPhone development, but before I can dive into that I have to get familiar with Objective-C and a few other things.</p>
<p>The first thing I needed was the development kit available for free from the Apple website. Just register as a developer (for free of course) and download the tool. Included in this download is XCode (which is an IDE, the place that holds all your code and resources together), Interface Builder (click and drag for building GUI&#8217;s), and the standard frameworks (including COCOA, the framework we need to know).</p>
<p>I just mentioned the COCOA framework. I&#8217;ll be up front and say that I&#8217;m probably not technically correct calling COCOA a framework. In reality it is a group of frameworks, the major ones being the Foundation Framework, AppKit Framework and Core Data Framework. There are more, but these are the three main ones. This collection of frameworks provide all the useful classes you need to build Apple Mac/iPhone software.</p>
<ul>
<li>Foundation Framework for providing base functionality.</li>
<li>AppKit Framework provides the user interface classes</li>
<li>Core Data Framework is essentially a persistance framework.</li>
</ul>
<p>Although I cannot recommend the entire book yet, but so far I have been progressing through COCOA Programming For MAC OS X by Aaron Hillegass. So far I have found this to be an excellent read. Usually with technical books I end up skipping the first few chapters to get to the good stuff, but even from chapter one of this book I have been enthralled. The first chapter provides a very quick but amazingly informative overview of where the MAC OS and the COCOA framework have evolved from.</p>
<p>Coming from an Object-Oriented perspective I have found Objective-C to be quite easy to pickup, and so far I would have to say I am quite impressed with the language. I wish I had found this a long time ago! My background of Object-Oriented programming includes C++, Java, PHP, Python and JavaScript. Objective-C claims to be a mixture of pure C and SmallTalk.</p>
<p>What is this Object-Oriented programming I hear you ask? Basically it is a programming paradigm that models the creation of software on (real-life?) objects. For example, if you were to build an accounting system you may identify the following objects&#8230;</p>
<ul>
<li>Documents</li>
<li>Journals</li>
<li>Ledgers</li>
<li>and of course&#8230; Accounts</li>
</ul>
<p>These are of course a very high level of abstraction, they can all then be broken down into what is known as Sub-classes, a less abstract view of the system&#8230;</p>
<ul>
<li>Documents can be specialised as&#8230;
<ul>
<li>Memos</li>
<li>Invoices</li>
<li>Purchases</li>
<li>Receipts</li>
<li>Cheques</li>
<li>etc</li>
</ul>
</li>
<li>Journals can be specialised as&#8230;
<ul>
<li>Purchase Journal</li>
<li>Sales Journal</li>
<li>Cash Receipt Journal</li>
<li>General Journal</li>
<li>etc</li>
</ul>
</li>
<li>Accounts can be specialised as &#8230;
<ul>
<li>Liabilities</li>
<li>Assets</li>
<li>Owner Equity</li>
<li>Revenue</li>
<li>Expense</li>
</ul>
</li>
</ul>
<p>And so on.</p>
<p>Each of these classifications (classes for short) can specify certain data and code that work together to define the class. The way of reaching the code in an object is usually described as calling a method or function on that object. Once the class is defined, then a software program can instantiate that class into an &#8220;Object&#8221;. Yes, we have gone the scenic route to get to this point <img src='http://www.mattsoftware.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>One of the neat things about Object-Orientation as a software paradigm is that you can put very general code into a Base class, and then create a specific class that extends from the base class, inheriting all the code and data that was in the base class, and then add more specialty code and data to it. Then you can specialise that code further but extending that class again and again until you have the most specialised class that is practical.</p>
<p>For example, following our Accounting example above, we may have a base class Document. The Document class will more than likely have an amount attached to it that is added to the system as a journal entry. But for record keeping we need to know more information. My design of such a system would include a class &#8220;Document&#8221;. It would have a piece of data attached to it which I would name &#8220;totalAmount&#8221;, which would be of type currency. I would probably have a method or to that could fetch and/or set that field, and another one which would fetch a description or summary of the document. I would probably write a method that returned &#8220;Generic Document&#8221; as the description of this class. As the Document class is very generic, I would decide to extend that class with different specialities of that base Document class, to provide more functionality, depending on the type of document that has been entered into the system.</p>
<p>The next class I would define would be the Receipt class. A receipt would extend the Document class, and in effect enable a receipt to also have a totalAmount available for an instance of this class. As this class inherits everything of its base class, if a piece of code asks for the objects description it will return &#8220;Generic Document&#8221;. Not a great idea, as we know it is a Receipt, so what we do is &#8220;Override&#8221; the description method to return a different message, &#8220;Receipt&#8221; for example. We may also add other data to this class if we wish, it might specify who the reciept was issued to, what products/services was involved etc.</p>
<p>Ok. Object-Orientation 101 completed. Although all the above is not 100% accurate for every language and system, the basic ideas are there. All we need now is away to get these idea&#8217;s into a software program. Enter Objective-C.</p>
<p>Objective-C uses &#8220;messages&#8221; to communicate between objects. So if you have an object, call it &#8220;weatherStationGoldCoast&#8221; and it has a method on it called &#8220;whatIsTheWeatherLike&#8221;. Say you also have another object, &#8220;airportSydney&#8221;. Somewhere, somehow in your software the AirportSydney object is executing code and needs to schedule a flight to the Gold Coast. Before it does this it would be a great idea to check to see what the weather is like at the Gold Coast to know if it will be safe to land the plane there. Easy! Simply ask the WeatherStationGoldCoast object by sending a message to the whatIsTheWeatherLike method. Finally some code&#8230;</p>
<pre style="padding-left: 30px; "><strong>// file: WeatherStation.h</strong>
#import <Cocoa/Cocoa.h>
@interface WeatherStation : NSObject
{
        // define data here
        (NSString *) stationName;
}
// define methods here
- (WeatherStation*) init : (NSString*) stationName;
- (NSString *) whatIsTheWeatherLike : (int)futureMintutes;
@end</pre>
<pre style="padding-left: 30px; "><strong>// file: WeatherStation.m</strong>
#import "WeatherStation.h"
@implementation WeatherStation
- (WeatherStation*) init : (NSString*) stationName
{
	// do something useful here, like load up the station data for the stationName
}
-(NSString*)whatIsTheWeatherLike : (int)futureMintutes
{
	// this would normall go and get some real data, say from the BOM for a point of time in the future
	// lets just say the weather is always fair on the coast (one day soon I'm sure it will rain, but not yet)
	return @"fair";
}
@end</pre>
<pre style="padding-left: 30px; "><strong>// file: Airport.h</strong>
#import <Cocoa/Cocoa.h>
@interface Airport : NSObject
{
}
-(BOOL) scheduleFlightTo: (NSString *)where
					when:(int)when; // how many minutes in the future to schedule the flight
-(void) scheduleFlight: (NSString* )where when:(int)when;
@end</pre>
<pre style="padding-left: 30px; "><strong>// file: Airport.m</strong>
#import "Airport.h"
#import "WeatherStation.h"
@implementation Airport
-(BOOL) scheduleFlightTo: (NSString *)where when:(int)when
{
	// first we need to get the gold coast object - lets make one now
	WeatherStation* gcWeatherStation = [[WeatherStation alloc] init: @"GoldCoast"]; // first allocate memory, and then run the init method on that allocated object - two calls in one <img src='http://www.mattsoftware.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
	NSString* weather = [gcWeatherStation whatIsTheWeatherLike:when];
	if ([@"fair" isEqualToString:weather] == NO) return NO;
	[self scheduleFlight:where when:when]; // all is good, actually schedule it
	return YES;
}
-(void) scheduleFlight: (NSString *)where when:(int)when
{
}
@end</pre>
<pre style="padding-left: 30px; "><strong>// file: main.m</strong>
#import <Cocoa/Cocoa.h>
#import "Airport.h"
int main(int argc, char *argv[])
{
	Airport* sydneyAirport = [[Airport alloc] init];
	BOOL result = [sydneyAirport scheduleFlightTo:@"GoldCoast" when:60]; // schedule flight in an hour
	if (result == YES) NSLog(@"Scheduled flight to the GoldCoast in 1 hour successfully");
	else NSLog(@"Flight cancelled - weather is no good");
	return 1;
}</pre>
<p>Some important notes for this code&#8230;</p>
<p>Header files define the template, or the interface of your class (wrapped with @interface and @end). Identifies starting with the ampersat symbol (@) are Objective-C identifiers. Firstly your data is defined between braces, and then your methods are defined after that. The minus symbol (-) before the method name indicates it is an object instance method, where a plus symbol (+) indicates its a static class method. The type is then defined between parenthesis, followed by the method name and then the parameter list. The first parameter in the list only requires a type and a variable name, and may be followed by a space and further variables. The rest of the variables defines a message parameter name, followed by a colon (:) followed by the type in parenthesis and finally the variable name. The variable name is what we use in our method to reference that parameter. The message parameter name is what the caller uses to reference that variable. I see some similarities with Python in this respect (warning, subjective statement ahead&#8230;). I like it! Just like C this is followed by the semi-colon to say this is the end of the statement. Remember this is just the interface, the implementation will be in the .m file.</p>
<p>The .m files indicate Objective-C Files. They can be a mixture of Objective-C and straight C, in fact, Objective-C is a superset of C. All valid C code is valid Objective-C code. In this file the implementation of the class template in the header file is filled out between the @implementation and @end tags. The method header is exactly the same as in the .h files, without the semi-colon at the end, and with code beween following braces.</p>
<p>Objective-C code works by sending messages between objects. What is slightly different about Objective-C is that the messages may or may not get responded to. This is different to languages like Java for instance where if you call a method on an object, the compiler enforces that the method must exist, and return a correct data type. In Objective-C you can send any message you like, but if the method doesn&#8217;t exist, you wont get a response. This is very cool (note I come from using dynamically typed langages lately, python specifically). You will note that messages are sent to objects using brackets. For instance if I wish to allocate memory for an Airport object, then I can send the alloc message to it, hence [Airport alloc]. Once the memory is allocated we can then initialise the object, by sending it the init message. We can also roll it all into one, as you can see above. Note that its not considered good practice to nest more than two sets of brackets, it just gets messy (my argument with Scheme like languages is the same by the way). Calling a method with multiple parameters is almost as easy, just follow the message name with a colon and the list of parameters (separated by spaces). The first parameter isn&#8217;t named, but the other ones you use the name and value separated by colon&#8217;s. E.g. [{object} {message} : {firstparamter} {paramname}:{paramvalue} {paramname}:{paramvalue}].</p>
<p>Another couple of notes. NSString objects can be created easily by sitting the ampersat symbol in front of it, hence @&#8221;this is a NSString&#8221;. You will also notice i&#8217;ve used the NSLog statement to print it out to the screen. You can use printf() type statements if you wish, you just need to convert the NSString object into a cstring (look for the cStringUsingEncoding method on the NSString class).</p>
<p>I have no doubt left out some things, possibly even vital things. I am only just learning this myself and all the views expressed are my interpretation of things etc etc etc. I hope this is useful for someone, somewhere at some time.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1611px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">#import <Cocoa/Cocoa.h></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1611px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">@interface Foo : NSObject</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1611px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1611px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>IBOutlet NSTextField *text;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1611px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1611px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">- (IBAction) seed : (id) sender;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1611px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">- (IBAction) generate : (id) sender;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1611px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">- (void) doSeed;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1611px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">- (int) doGenerate;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1611px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">@end</div>
]]></content:encoded>
			<wfw:commentRss>http://www.mattsoftware.com/wordpress/2009/12/12/object-orientation-objective-c-primerbasics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First week with the Mac</title>
		<link>http://www.mattsoftware.com/wordpress/2009/12/05/first-week-with-the-mac/</link>
		<comments>http://www.mattsoftware.com/wordpress/2009/12/05/first-week-with-the-mac/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 23:08:45 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.mattsoftware.com/wordpress/?p=48</guid>
		<description><![CDATA[Wow. What a week!
Moving to the Mac for me has been a pleasantly easy move. Sure there are a few quirks that I need to get used to, but I&#8217;m actually finding myself started to get frustrated with the keyboard shortcuts under Linux now. I keep going for the Mac equivalent and it just doens&#8217;t work. Thats [...]]]></description>
			<content:encoded><![CDATA[<p>Wow. What a week!</p>
<p>Moving to the Mac for me has been a pleasantly easy move. Sure there are a few quirks that I need to get used to, but I&#8217;m actually finding myself started to get frustrated with the keyboard shortcuts under Linux now. I keep going for the Mac equivalent and it just doens&#8217;t work. Thats a good sign that the mac shortcuts are very intuitive. So far so good!</p>
<p>I thought I would breif my first week on the mac by listing the third party tools I have downloaded so far. I expect to talk a little on each of the apps over time, but these are my must have first week apps (well, at least the ones that make me comfortable coming from the Linux perspective).</p>
<ul>
<li>Adium (multi-messenger client, no video yet wich really sux as I now have a webcam built into my laptop)</li>
<li>Thunderbird</li>
<li>Google Chromium (until Chrome is released)</li>
<li>FireFox (mainly for the plugins, firebug, foxyproxy, yslow, etc)</li>
<li>XCode (development suite from apple)</li>
<li>DivX Player</li>
<li>MacVIM (port of Vim to Mac, where would I be without VIM!)</li>
<li>Remote Desktop Connection (from Microsoft &#8211; essential for administering remote windows machines)</li>
<li>VirtualBox (virtualization from Sun)</li>
<li>Google Voice and Video &#8211; Video chat from GMail</li>
</ul>
<p>And of course these included apps that Apple have provided&#8230;</p>
<ul>
<li>Terminal (if your not comfortable here then you havn&#8217;t come from a Linux background!) (and its bash, double kudos)</li>
<li>Subversion (version control) &#8211; SVN out of the box &#8211; COOL!</li>
<li>SSH (secure shell) &#8211; As this is the main method I use to access remote machines, I would really be at a loss without it.</li>
<li>rsync (remote sync protocol)</li>
<li>iTunes (how else do I sync my iPhone <img src='http://www.mattsoftware.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>iDVD &#8211; Very nice interface for DVD burning</li>
<li>Garage Band &#8211; If only I had an interface to plug my guitar into this piece of software. Looks unreal, I would just like to start playing with it.</li>
</ul>
<p>The first week would not be complete without a few essential items I have setup particularly to make life easier.</p>
<ul>
<li>Time Machine
<ul>
<li>This is the first app I used. Connect a removable hard drive, set it as a TimeMachine target, and it backs up your entire drive!</li>
<li>It even has an awesome GUI for retrieving older backups.</li>
</ul>
</li>
<li>Multiple Desktops (System Preferences -&gt; Expose and Spaces -&gt; Enable Spaces)
<ul>
<li>Use &#8220;Apple-&lt;num&gt;&#8221; to go directly to a screen</li>
<li>Use &#8220;Apple-&lt;arrow&gt;&#8221; to navigate to the next/prev/up/down screen</li>
<li>Check the &#8220;When switching to an application, switch to a space with open windows for the application
<ul>
<li>This is a weird one from a Linux perspective. When you click on an icon in the dock it goes to the open application. This is unlike GNome for example as when clicking on terminal a new window will appear. On a mac it will switch to that application. I turned this option off for a while but found it best to leave it on. The only real application I use that require a new window when I click on it is terminal, and so far I am right-clicking on the terminal doc icon -&gt; new window -&gt; basic, to get a terminal window. Its not too annoying as of yet, but I would like to not have to go through to basic &#8211; new window should bring up my default new window.</li>
</ul>
</li>
</ul>
</li>
<li>Change keyboard shortcut to change between windows of a desktop
<ul>
<li>Unlike Linux (and Windows might I add) using &#8220;Apple-Tab&#8221; does not scroll through open windows, it scrolls through open applications. So once you are at an application you need another shortcut to scroll between the windows of that app, this one is &#8220;Apple-`&#8221;. Note of course this only switches through open windows of that application on the current desktop. If you want to cycle through all the windows, then simply click on the doc icon for the next window, this does go across desktops as well.</li>
<li>To change between windows on the current desktop, regardless of if they are of the same app, I have modified my shortcut key to &#8220;Apple-Opt-Tab&#8221;. It works well and is not too hard to either remember or type (from memory the default was &#8220;fn-Ctrl-F4&#8243;, and was quite annoying if you do it often)</li>
</ul>
</li>
<li>Page up and Page down keys are missing from my MacBook
<ul>
<li>Using &#8220;fn-&lt;up/down&gt;&#8221; seems to do the trick for me.</li>
</ul>
</li>
<li>Multitouch &#8211; AWESOME!
<ul>
<li>The multi-touch touchpad works really well.</li>
<li>Scroll up/down &#8211; double touch scroll. This is really easy and I find myself not even needing to use the keyboard for this.</li>
<li>Back/Forward when browsing &#8211; triple touch swipe left or right.</li>
<li>View destktop &#8211; quad touch swipe up</li>
<li>View Expose (overview of open windows) &#8211; quad touch swipe down</li>
</ul>
</li>
</ul>
<p>So for so good for the Mac. I dont feel like I&#8217;m too unproductive on it yet, so thats a good thing. I expect the next few weeks will be getting used to XCode and Cocoa libraries for mac/iphone development.</p>
<p>Wish me luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattsoftware.com/wordpress/2009/12/05/first-week-with-the-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving life to the Mac</title>
		<link>http://www.mattsoftware.com/wordpress/2009/11/27/moving-life-to-the-mac/</link>
		<comments>http://www.mattsoftware.com/wordpress/2009/11/27/moving-life-to-the-mac/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 07:54:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.mattsoftware.com/wordpress/?p=41</guid>
		<description><![CDATA[It&#8217;s done. I&#8217;m now officially a mac user. I must admit this has been a while in the making. I had never even considered a mac until they released OSX. The thought of apple moving their OS to a Unix (BSD) backend really appealed to me. To make sense of that statement a little about my history [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s done. I&#8217;m now officially a mac user. I must admit this has been a while in the making. I had never even considered a mac until they released OSX. The thought of apple moving their OS to a Unix (BSD) backend really appealed to me. To make sense of that statement a little about my history with computers&#8230;</p>
<p>Commodore 64 was my first machine. It was a Christmas presant around 1984 I would guess. I almost even remember the day! I certainly remember the many hours typing endless lines of code out of books we found in bargain bins. I have to admit I did not learn much about programming, or much about anything really, but I did pick up the programming bug during those years. C64 Basic was kinda fun.</p>
<p>Next came school. Macs were all the rage there. Pascal was taught as part of senior year computer classes which I believe I did quite well. This is where I started actually programming, being able to turn lines of code into something that actually did something, by myself (no need to mindlessly type code out of a book).</p>
<p>Out of school was TAFE with a 6 month part time course in Visual Basic. Now with the right tools I was able to program database applications with graphical interfaces! Sure it was still basic, but I was developing more interesting utilities. I had even started using the internet and developing HTML based websites at this stage and found a library to help me turn my visual basic programs into DLL files to use with the Microsoft Personal Web Server. Now I could write programs for the web (not that I realised what that really ment at the time). My first (and only) program using this method was a computer system quoting tool for the computer shop I was working at. To be honest I thought it was quite neat. Nothing like that existed at the time from what I can tell, and I think my boss was quietly impressed. We could generate quotes, in house,  for customers in seconds rather than minutes (looking up supplier pricelists, getting cost prices, adding margin, writing up the quote etc). A few clicks of dropdown lists, a few checkboxes for options, click submit, click print, a semi-proffessional quote was printed out which we could explain to the customer and stand by the number that was printed out. That experience was fun.</p>
<p>At the same time I was experimenting with Linux. RedHat 5.4 from memory. Either I wasn&#8217;t ready for it or it wasn&#8217;t ready for me. I just wasn&#8217;t experienced enough to even get it to install. I could install windows 95 machines blindfolded (in fact I remember doing at least 2 installations without monitors, I had all the keystrokes practically memorized), I could fix numerous bugs with dos/windows3.11/windows95 machines, I was at the stage where I could fix peoples problems over the phone 90% of the time (although 90% of the problems were printer related and required talking through setting up print drivers). But I did not understand enough about actually how a computer worked to answer the relevant questions in the clunky install process of RedHat 5.4. Soon after I found RedHat 6.0, which I successfully installed and started using. Within a few months I completely wiped my harddrive and used Linux exclusively which was a challenge. It was 6 months before I could actually do the same things I was doing with MSWindows based machines. Frustrating at times, but I stuck at it. This is where I picked up a little perl, and was introduced to PHP.</p>
<p>After getting bored with the small town computer shop work I moved away to attend Uni. I continued to do a lot of perl programming but was also caught up with javascript (for part time employment) and c++ (subject matter). At this stage I was 100% Linux, using MSWindows only at Uni on their machines if I needed to do word or excel.</p>
<p>Moving on to second and third year of Uni introduced me to java, lisp, haskell and assembly. My honours year bought me back to the MSWindows world. It was a requirement for my thesis that I used MSWord with Endnote. I obtained a notebook with windows pre-installed and kept Linux on my PC at home.</p>
<p>This also happened out of Uni. I worked for a web-design company, using their computers which had Windows, developing mainly in ColdFusion and a little PHP. My second job was fulltime PHP, with a supplied laptop which had MSWindows, but also enabled me to maintain a Fedora based server for their website, and a duplicate for the test server. It wasn&#8217;t long until I scrapped the MSWindows partition and just went fulltime Linux once again (also running VMWare Server &#8216;just in case&#8217; some of the windows programs I was using was needed again). My current position has me maintaining linux based servers, so the first thing I did with the supplied computer was to trash it and put linux on it.</p>
<p>I must admit I have spent endless hours over the years fixing issues between linux drivers and hardware which already have windows drivers. Every time it has been extremely satisifying to get things working that seem almost impossible to do. I remember the entire weekend getting the HP laptop to even recognise it had a wireless ethernet card in it. And then the entire next weekend to get it to recognise an encrypted signal. My time was probably worth more than a windows disc, but the satisfaction of getting everything to work using Free and Open Source Software (FOSS) was well worth the effort put into it.</p>
<p>However&#8230;</p>
<p>I do get frustrated sometimes at how compatible linux drivers are with current hardware, and the lack of certain support of some devices, and the less than satisfactory support of linux on laptop computers. I understand all the arguments, but it is still frustrating that my laptop takes 4 minutes to hibernate (using windows it takes about 30 seconds) and can take up to 10 minutes somedays to come out of hibernation (I suspect its because it had certain usb devices when it was hibernated, and missing those devices on wakeup, but I am not sure). So after some particularly bad news, and feeling like a change is as good as a holiday, and after owning an iPhone for about 4 months and really wanting to get into iPhone development, all thrown into a pot and boiled for a day or two, it was decided that a Mac was a fantastic idea (probably not the best time to actually make decisions, but history will tell if it was a good one or not).</p>
<p>So here I am, with a Mac, writing my first serious blog post.</p>
<p>More experiences to follow&#8230;</p>
<p>To be continued&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattsoftware.com/wordpress/2009/11/27/moving-life-to-the-mac/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
