Category Archives: Cocoa

A couple of screenshots

Just a couple of screenshots for the two utilities I wrote and blogged about earlier. Of course, the UI and the application logic for both these apps needs a lot more polish to make them true Mac apps, but I am swamped with work. I did put them up on Google Code with a GPL license (see the original announcement above) if someone wanted to improve them. Click on the thumbnails to get a bigger view.

cocoagcalc screenshot

visualdot screenshot showing usage of neato

Advertisements

Standing on the Shoulders of Giants

“If I have seen further it is by standing upon the shoulders of giants.”

–Isaac Newton

Well, it is that time of year again–university summer classes. I won’t update this blog as frequently as before, but I will try to post from time to time, depending on how much time I can free up.

I made two small Cocoa projects on Google Code which leverage existing code and tools(hence the quote above)

visualdot

cocoagcalc

I have uploaded the code and binaries from a different machine instead of my Mac, so let me know if something is broken.

Acknowledgments:

  1. Andreas Mayer for AMShellWrapper
  2. Greg Miller for gcalc


A RubyCocoa Regular Expression Checker

Update: 6:45 p.m. GMT, As far as I know, you can just install the binary package of RubyCocoa and the default Apple installation of Ruby will be sufficient to make this app work.

Update: 6:19 p.m. GMT, I fixed a bug in the checker. Get the new one as usual from the Box widget.

Application icon credits: rox-ruby

I have uploaded a little Regular Expression checker I made in RubyCocoa(see RegEx.dmg in my Box widget to your left). I only have an Intel Mac to test it on, so I have no idea whether it will run correctly on PPC Macs. The code is licensed under the GPLv2. It may be the case the that you need RubyCocoa properly installed to run this app. See my post on installing BioRuby for Mac OS X for a link to Dan Benjamin’s instructions on updating your Ruby installation(adapt these instructions accordingly for Ruby 1.8.5). For installing RubyCocoa under Ruby 1.8.5, if memory serves, these commands (once you extract the files from the archive and go to the to-level directory of RubyCocoa),

$ ruby install.rb –help # print all options

$ ruby install.rb config

$ ruby install.rb setup

from this website are the key instructions. You may have to prefix sudo in one of the above three commands.

Screenshot:

Screenshot


			    NO WARRANTY
  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.

Things to look for when programming in Cocoa(using Objective-C)

For all the power you get from dynamic typing, you also get the power to really “hurt yourself”.Because Objective-C is dynamically typed, one must pay really close attention to the warnings the compiler generates. Often these “warnings” are the compiler telling you that something won’t work at runtime. For example, a common warning is something like(and these are my own words): “I am not sure this receiver accepts this message”. That means you are probably not sending the right message to the object (message \approx member function, receiver \approx object(pointer to the object). Also, pay close attention to the “Run Log” of Xcode when you are debugging. Any runtime exceptions, while cryptic at first, will make a lot of sense once you gain a bit of experience with Cocoa

Ditch the #define “constants”

If you find yourself using a lot of #define X 10 (or other integers) for constants in your Objective-C code, stop! #define is parsed by the preprocessor and not the compiler(last I heard). It is more or less a search and replace of X with 10 by the preprocessor in the above example. It is not seen by the debugger or anything(since it is not a symbol). So, I would suggest enum.

enum values {first = 10} constant;

constant X = first;

This might be inconvenient if you only have a couple of #defines laying around, but it is better to use enums instead of large chunks of #define (even Apple uses enums ! — check the QuickTime 7.1 reference). Also, the author of Magic Number Machine (Matt Gallagher) uses enums extensively