Example Cocoa code
12/12/08 05:07
It always seems odd how it is difficult to find
examples of the application you are working on. For
me, just starting to learn Cocoa, tutorials and
example applications have been the key to my
learning. But for some reason you can never find
the right tutorial to sort out the problem you are
working on.
With this post I'm releasing some of my code into the wild for those new to Cocoa development. I'm not going to claim that the quality of the code is great and it doesn't really do anything very special, but it is out there and might help a few people solve some of the more basic problems that I had to initially deal with.
For the record, the application is designed to do some basic analysis for a tunnel, estimating the Fenner-Pacher curve. Some of the key Cocoa concepts in the application are:
You can download my source code here.
With this post I'm releasing some of my code into the wild for those new to Cocoa development. I'm not going to claim that the quality of the code is great and it doesn't really do anything very special, but it is out there and might help a few people solve some of the more basic problems that I had to initially deal with.
For the record, the application is designed to do some basic analysis for a tunnel, estimating the Fenner-Pacher curve. Some of the key Cocoa concepts in the application are:
- Use of Core Data
- Use of triggerChangeNotificationsForDependentKey for automatically updating data
- Creating a graph which automatically updates using tableViewSelectionDidChange
- Performing mathematical and engineering calculations
You can download my source code here.
Learning Cocoa
24/11/08 19:59
Over the last few months I've been trying to learn
programming using Cocoa, one of the native
programming languages for a Mac. It's been a tough
learning curve. Until trying to learn Cocoa I've
only really developed rather basic scripts with
languages such as Visual Basic, Applescript and
FISH. I've never had any formal training in
programming so it's all been a bit of a struggle. I
decide not to learn through books, even though
there are few very highly rated books out there.
The internet is such a great resource it seemed
obvious that there must be some great tutorials out
there.
Well I have to say that it is true, there really are some great resources out there. The trouble is there is no structure to it. There is no way to find out which tutorial you should start with and where you should go from there. It took me a bit of stumbling around in the dark to try and find my way around it all. I must admit that there are a few tutorials that I have done more than once and still don't understand, and that is despite the tutorials being describe as 'for beginners'. The penny has finally dropped though, I have suddenly started to understand Cocoa and that is because I happened to find a sequence of tutorials that seems to have worked. If you want to have a go at learning Cocoa, try this sequence. I hope it will as well for you as it did for me.
- The first stage is to go through an excellent short PDF manual called Become an Xcoder. This really does require no prior knowledge of C, C++ or any other language that most manuals assume the reader has. It gives the reader sufficient knowledge to understand what is happening in all the different sections of a project as well as working with basic classes such as arrays or strings.
- The next stage I would recommend is to do Apple's tutorial. To understand fully what is going on in this tutorial you do need some knowledge of the code structures used by Cocoa, but having been through 'Become and Xcoder' you should be ready for this. The one problem with Apples tutorial is that the latest version is based on Leopard and Objective C 2.0. If you don't have leopard, you aren't out of luck, there are still some examples using older versions of Xcode on the internet. This tutorial is useful because it gives you an understanding of some of the non code related issues associated with creating an application.
The latest Cocoa tutorial on the Apple Developer site
An older version of the Apple currency converter tutorial
- The next stage I would suggest is to go to CocoaDevCentral.com and go through the tutorials on the front page. These are some excellent tutorials dealing with some of the other features of Cocoa such as core data and working with graphics. Doing this will give you a fair understanding of how easily accessible some of the features of Cocoa are.
CocoaDevCentral
- Finally I would recommend looking at a larger project and taking it appart to understand how it works. An excellent example of this is a simple calculator app prepared by Apple. Being such a simple application we all understand what it needs to do, making the methods within the application much more accessible. Having been through all of these tutorials you should be able to understand what almost every line of code in the project does. You can then start adding your own buttons and code to the calculator to try out your own skills.
- Now, the world is you oyster. It is now time to start branching out to develop the type of application that you want to do. Once source I would suggest that you have a look at is MacDevNet. It includes two excellent podcasts, CocoaCast for those wanting to do more work on the basics and LateNightCocoa, a well produced series of interviews with Cocoa developers. MacDevNet
I hope this might help out a few people who are starting out or struggling with Cocoa. For a beginner it is a very steep learning curve but it will be well worth it in the end.
Well I have to say that it is true, there really are some great resources out there. The trouble is there is no structure to it. There is no way to find out which tutorial you should start with and where you should go from there. It took me a bit of stumbling around in the dark to try and find my way around it all. I must admit that there are a few tutorials that I have done more than once and still don't understand, and that is despite the tutorials being describe as 'for beginners'. The penny has finally dropped though, I have suddenly started to understand Cocoa and that is because I happened to find a sequence of tutorials that seems to have worked. If you want to have a go at learning Cocoa, try this sequence. I hope it will as well for you as it did for me.
- The first stage is to go through an excellent short PDF manual called Become an Xcoder. This really does require no prior knowledge of C, C++ or any other language that most manuals assume the reader has. It gives the reader sufficient knowledge to understand what is happening in all the different sections of a project as well as working with basic classes such as arrays or strings.
- The next stage I would recommend is to do Apple's tutorial. To understand fully what is going on in this tutorial you do need some knowledge of the code structures used by Cocoa, but having been through 'Become and Xcoder' you should be ready for this. The one problem with Apples tutorial is that the latest version is based on Leopard and Objective C 2.0. If you don't have leopard, you aren't out of luck, there are still some examples using older versions of Xcode on the internet. This tutorial is useful because it gives you an understanding of some of the non code related issues associated with creating an application.
The latest Cocoa tutorial on the Apple Developer site
An older version of the Apple currency converter tutorial
- The next stage I would suggest is to go to CocoaDevCentral.com and go through the tutorials on the front page. These are some excellent tutorials dealing with some of the other features of Cocoa such as core data and working with graphics. Doing this will give you a fair understanding of how easily accessible some of the features of Cocoa are.
CocoaDevCentral
- Finally I would recommend looking at a larger project and taking it appart to understand how it works. An excellent example of this is a simple calculator app prepared by Apple. Being such a simple application we all understand what it needs to do, making the methods within the application much more accessible. Having been through all of these tutorials you should be able to understand what almost every line of code in the project does. You can then start adding your own buttons and code to the calculator to try out your own skills.
- Now, the world is you oyster. It is now time to start branching out to develop the type of application that you want to do. Once source I would suggest that you have a look at is MacDevNet. It includes two excellent podcasts, CocoaCast for those wanting to do more work on the basics and LateNightCocoa, a well produced series of interviews with Cocoa developers. MacDevNet
I hope this might help out a few people who are starting out or struggling with Cocoa. For a beginner it is a very steep learning curve but it will be well worth it in the end.