Wednesday, May 27, 2009

MyCompanyName

All files XCode creates , includes a copyright notice in the form of __MyCompanyName__:

//

// MyFile.h

// MyProject

//

// Created by Joe Smith on 27/05/09.

// Copyright 2009 __MyCompanyName__. All rights reserved.

//


This setting can be modified using defaults, the command line tool for editing system and application preferences. Open the terminal application and enter the following:

defaults write com.apple.xcode \
PBXCustomTemplateMacroDefinitions \
'{ ORGANIZATIONNAME = "Ergun's Playground"; }'

The new file heading will appear as:

//

// MyFile.h

// MyProject

//

// Created by Joe Smith on 27/05/09.

// Copyright 2009 Ergun's Playground. All rights reserved.

//


Thursday, May 21, 2009

Garbage Collection in Objective-C

As of Objective-C 2.0 garbage collection became available. With garbage collection you don't have to worry about retaining or releasing objects, auto-release pools or  retain counts. 

The method calls, autorelease, release, retain, and dealloc will be ignored in garbage collection enabled process.

However the iPhone environment doesn't support garbage collection. Also if you deploy a garbage collected library, older non-garbage collected processes using your library will be in trouble (will probably leak memory.)

So from portability point of view, it looks like you will have more reasons to turn-off garbage collection, and "do it yourself"  until old systems phase out and iPhone runtime (if ever) supports GC. If your app is brand new and doesn't have coupling with the older processes then you may take advantage of GC.

Sunday, May 17, 2009

Books

This book is fantastic. Excellent for novices, as well as for highly experienced C/C++ programmers. I was able to fast read the first 200 pages in couple of hours and started practicing short examples. It is a thorough introduction to Objective-C language and Cocoa Foundation Framework.

Saturday, May 16, 2009

Build a static C library and link to an executable



At various stages in my programming career I did security coding in C and C++. Recently I discovered a hash function library from security guru Bruce Schneier, called Skein.

My friend Ricardo Machado kindly provided me a command line test utility he wrote for Skein. My objectives were, using XCode development environment:
  • Compile Skein as a static library
  • Compile the test program and link to Skein static library
The major issue for me is to have the static library project referenced by the test executable project, so that when library code changes and the test program is rebuilt, both library and test executable's binaries are updated and re-linked automatically. This is standard 'make' logic, and it wasn't easy to discover under XCode.

It is fairly easy to create individual projects from XCode, one for static library and the other for the test app, ie. "libskein.a" and "test" respectively. Once you do that, open the test project, then drag and drop library project file "skein.xcodeproj" under "test" project:

Then go to "Targets" under XCode navigation tree and select "test". Right-click and select "get Info":

Click the "+" button and add a relative reference to libsekin.a. This will ensure that libskein is built and re-linked with test whenever necessary.

Other References:

Confessions of a convert

Hi

Finally I switched to Mac. Windows Vista was turning point for me. I asked myself "if a new version of a product is worse than previous one, do I need to put up with this?" 

Switching has been so far smooth. Inevitably there is some learning curve, but I am prepared for this. 

The purpose of this blog is to keep notes about the Mac environment and share them with the world. My primary focus would be in the software development area.

As an experienced Windows software developer, I would like to explore the possibilities offered by Mac. I am primarily interested in Cocoa and iPhone development environment. 

My first-phase plan is:
  1. Learn Objective-C
  2. Learn Cocoa
  3. Port my password management tool into Mac
  4. Learn developing Dashboard gadgets
  5. Learn developing iPhone gadgets
My second-phase plan is:
  1. Learn Python
  2. Learn Google App engine
  3. Deploy my Mac utilities at a Google App engine site
Programming and learning new technologies are my life-long passions. I urge everyone to find and follow their passion.

How to recover from Mac Book Pro catastrophes

Synopsis DISCLAIMER: This article applies to Intel based MacBook Pro 4th generation models with a Touch Bar (2006-2020.) The methodology giv...