Saturday, September 19, 2009

Setting Up a Repository

To setup an SCM repository on Mac:

mkdir -p /Users/Shared/Subversion/MyProject
cd /Users/Shared/Subversion

Make sure the repository will be readable, writeable, and listable for all users:

svnadmin create MyProject
chmod -R a+rwX .
ls -l MyProject

Create subversion configuration directory:

ergun-coruhs-imac:Subversion ergun$ svn status
svn: warning: '.' is not a working copy
ergun-coruhs-imac:Subversion ergun$ 

The default configuration file is now at .subversion/config in your home directory. You must edit config file to exclude binary files (such as build/*) out of SCM repository. However .subversion is a hidden folder. You must make .subversion folder visible first to locate and edit the config file.

Inside config file, uncomment this line, and add the following wildcards to exclude them from SCM:

global-ignores = ... build *.nib *.so *pbxuser *.mode *.perspective

Uncomment this line:

enable-auto-props = yes

Add these to the [auto-props] section at the end of the config file:

*.mode* = svn:mime-type=text/X-xcode
*.pbxuser = svn:mime-type=text/X-xcode
*.perspective* = svn:mime-type=text/X-xcode
*.pbxpoj = svn:mime-type=text/X-xcode

Save and exit.



Showing hidden files in Mac

 Launch Terminal, and run these commands

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

Entering the two lines above into Terminal will allow you to use the Finder to display all of the hidden files on your Mac. The first line tells the Finder to display all files, regardless of how the hidden flag is set. The second line stops and restarts the Finder, so the changes can take effect. You may see your desktop disappear and reappear when you execute these commands; this is normal.

Thursday, June 18, 2009

Target-Action Design Pattern

The target-action approach to event-driven systems allows for a much greater deal of dynamism when compared to other, more static approaches, such as by subclassing. That is because subclassing is a relatively stiff way of programming - the programmer has to lay out the internal interconnection logic of a program at design time and this cannot be changed later (unless the program is stopped, reengineered and built again). On the other hand, target-action based programming can change these completely at run-time, thus allowing the program to create new inter-relationships and completely novel behavior all by itself.

A prime example of this approach is the OpenStep API, which partly thanks to being based on the dynamic Objective-C language, has much of its graphical user interface implemented by using the target-action paradigm. Consider the following example (written in the Objective-C language):
[button setTarget: self];
[button setAction: @selector(doSomething)];
Now when the button identified by the button variable is pressed, the runtime system will try to send a message named doSomething to the object in which this code has been invoked. It is also very well possible to determine the message to be sent at run-time:
[button setTarget: self];
[button setAction: NSSelectorFromString([textField stringValue])];
Here the message which is to be sent is determined by consulting a text field's string value (the string of text which the user typed into a text field). This string is afterwards converted into a message (using the NSSelectorFromString function) and passed to the button as its action. This is possible because, under Objective-C, methods are represented by a selector, a simple string describing the method to be called. When a message is sent, the selector is sent into the ObjC runtime, matched against a list of available methods, and the method's implementation is called. The implementation of the method is looked up at runtime, not compile time.

http://en.wikipedia.org/wiki/Target-Action

Tuesday, June 16, 2009

Cocoa Data Overview

The Core Data framework provides generalized and automated solutions to common tasks associated with object life-cycle and object graph management, including persistence:

Monday, June 15, 2009

Apple Cocoa Developer Tutorials


If you are into developing Apple GUI applications you need to learn writing Cocoa applications with Xcode. This is where it begins:


and this is the first tutorial (Currency Converter) you need to go through:


You will learn about actions, outlets, MVC design pattern and more.



Saturday, June 13, 2009

Xcode Save All option

Xcode development environment is really powerful. However it takes a while until you learn whereabouts of features. For example, Save All menu option is not available from the File menu directly. You need to press the option key to see alternative set of menu options under the File menu among which you would spot Save All.

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.

iTerm2 - How to auto-close sessions and auto-exit when last one closed

 Problem There are two problems when you close sessions and windows in ITerm2. When you gracefully exit from ITerm2 sessions with a recommen...