Saturday, November 17, 2012

NSLog Format Specifiers

These formatters are used with NSLog, and also Logging.h mentioned in a previous post. Take a look.

%d, %isigned int
%uunsigned int
%ffloat or double
%efloat or double in standard form or scientific notation
%xhex int
%Xhex int
%ooctal int


int num=9;
NSLog(@"The value of the integer is %i", num);

Result: The value of the integer is 9

NSDate *today= [NSDate date];
NSLog(@"the date is %@",today);

Result:  the date is 2012-11-17 01:15:00 +0000

Monday, November 12, 2012

How to add an existing Xcode project to Source control

If you create a project in Xcode and later you want to add it to source control then you need to run a couple of command line controls. But it's easy.

1. Quit Xcode.

2. Open terminal and navigate to your directory. Using something like:
cd Developer/myprojectname
There is a file in Xcode that we do not want to add to source control. This records the Xcode environment state. Because we're doing this adding manually, we have to tell Git manually to ignore it. If we had told Xcode to add the project to source control when we created the project it would have ignored this file automatically.

3. Type the find command to find the file file.
find .
The file we are looking for is UserInterfaceState.xcuserstate

4. Place the file name into an exclude file.

echo myproject.xcodeproj/project.xcworkspace/xcuserdata/John.xcuserdatad/UserInterfaceState.xcuserstate >.gitignore

This will create the file gitignore

5. Initialise Git
git  init
Did you get an error? (See bottom of post)

6. Add the files
git add .

7. Commit the files to the repository

git commit -m "write a short comment here"

Problem with Git?
Are you getting the command not found?

bash: git: command not found
This can be solved by:

  1. Open Xcode
  2. Open Preferences
  3. Chose the Downloads tab, choose components
  4. Instal the Command line tools.
Bob's your uncle.

Saturday, November 10, 2012

How & why incentives do not work

Firstly, if you have 18 minutes to spare, then rather than read this, go and watch Dan Pink's video at It really is food for thought.

In short, Dan says that proof exists to support the statement that incentives - the carrot or the sharp stick - do not work.
They do not work in many types of work. Not all, but most that we are likely to deal with.

But, and here's an interesting thing. Not only do they not work, they actually do harm. They give the opposite of the desired effect.

The candle problem
Dan starts by looking at the the candle problem.

If you give people the following: a candle, a box of pins and some matches, and you then ask them to fix the candle to the wall so that the lit candle's wax doesn't drip onto the table. How could this be done? and do they perform?

(A clue. To solve this you over come functional fixedness)

Do incentives work
If you incentivise this task, i.e. if you give a group incentives such as, 'if you're the fastest you'll get £50, if you're in the top 10% you'll get £20'. Then you get interesting results. (these £ values were not the ones used in the quoted experiement but I have adjusted for inflation :).  I'm sure the experiment holds)

The team that were given the financial incentives actually did a lot worse, and this is not a freak of this experiment or of this challenge. There are many more examples and experiments that back this up.

The solution to the candle problem?
It is at the bottom of the blog page.

Restate the problem and...
If you restate the problem as in this diagram and still give incentives, then the incentives make a significant difference. They have the desired effect and deliver an improvement in performance.

I think it's clear to see why when you realise the pins are no longer in the tray that was being used to collect them together.

So incentives appear to work for mechanistic, well defined tasks, but not for jobs that require creative thought. If the work is clearly defined and has an easy to see goal then the incentives work. It is almost as if the value of the incentive narrows the focus through a fear of losing the sweet carrot or money, or fear of meeting the pointy end of the stick.

This kind of left-brain work seems ideally suited to incentives but more and more our work is right-brain - creative, inventive.

A couple of quotes:
As long as the task involved only mechanical skill, bonuses worked as they would be expected: the higher the pay , the better the performance. 
But once the task called for "even rudimentary cognitive skill," a larger reward "led to poorer performance."

D. Ariely, U. Gneezy, G. Lowenstein, & N. Mazar, Federal Reserve Bank of Boston Working Paper No. 05-11, July 2005; NY Times, 20 Nov. 08

Autonomy - Mastery - Purpose
If we can no longer motivate using incentives or threats then what can motivates?
Dan suggests:
Autonomy - the urge to direct our own lives
Mastery - to get better and better at something
Purpose - the urge to be a art of something bigger than ourselves.

Traditional management
Management is a recent concept and it did not emanate from nature. It's an invention from mankind. It's ideal for compliance but it does not mean that it's always right. Maybe, at times, we need to rethink the management styles based on the three themes above.

I currently work in a very traditional environment and have found myself in a team of dispirited developers that distrust management, distrust each other, and are distrusted by management. I'm stuck in the middle as a Development Manager. My approach has been to apply two themes to improve things. One, traditional management - that is, clearly manage the tasks, the projects and the list of work. Senior management folk like that and the developers do too. The estimates are still off a bit but we can work on that.
The other theme is non-traditional. I encourage Mastery and Autonomy in the way I treat developer tasks and collaboration. I expand their range of influence and never pass on their successes as my own up the traditional management line. I motivate by letting them motivate themselves.
Warning. Senior management don't get this. Not mine anyway and that's probably why my days will be numbered. But I'll keep on trying. It's the only right way.

The answer.

Friday, November 9, 2012

Pages 4.2 not linking to iCloud - This is not your primary account

I have Pages on my iPad and Mac mini, and also my iMac. But I have recently upgraded the OS on my Mac Book Pro to Mountain Lion and Pages and Numbers don't connect to iCloud.

I checked the version of Pages - 4.2. So that should be ok.
I tried to update it from App store and of course it said don't be silly.

I went to iCloud in System Preferences and signed in. All I saw was the oportunity to select Mail, Contacts, Calendars and Notes. What I really wanted was shown below.

The iCloud form told me that I was not logged in with my primary account. But I was.

The task is to delete the iCloud account from the Preferences and log in again.

To do this un-tick the Contacts, Calendars and Notes. Try to untick Mail but it might complain.
If it does complain go to mail and remove the mail account.
Then go to Preferences again and untick the Mail. Now remove the iCloud account by using the "-".

Now add your iCloud account and ensure you tick "Documents & Data".

Now go to Pages etc and when you start it should let you look at your iclid files.

Just the ticket.