Sunday, December 25, 2011

NSNotification

It seems every NSNotification has a method named "object" returns the real UI element fires this notification. For example, in table view, when user click one item in the table view, a "NSTableViewSelectionDidChangeNotification" is fired, and the delegate will receive it. Then the delegate can use [aNotification object] to get the real table view. So it won't need to save a outlet of the table view.

Monday, December 5, 2011

How to import Xcode project into bitbucket

BitBucket supports private repository for free users, so it is very suitable for hosting our Xcode projects :)

When you signup your free account, and create a new project for yourself, the problem is coming, how to import your xcode project into the bitbucket?

1. Create your SSH key

First, you need to update your SSH key(s) into bitbucket, as we're OS X users, so it is very :)

1.1 Check your SSH key

In console, type:

$ls ~/.ssh<enter>

If there are id_rsa and id_rsa.pub exist, you've already got your SSH keys, so skip the next step.

1.2 Create your SSH key

In console, type:

$ssh_keygen<enter>

The program will ask you for a passphrase, you can just take it as a "password". And when the program finishes, there will be two files in your ~/.ssh

  • id_rsa - which is your private key, you need to protect this file, don't be touched by others.
  • id_ras.pub - which is the pub key, you can upload / send this file to others, such as bitbucket.

So we have our SSH key, then we upload it to bitbucket

2. Update your SSH key to bitbucket

Go to Bitbucket settings, click the "choose key", and browser to your id_rsa.pub (you may need to copy it to some directory that the finder can locate it, for example, in console, use: cp ~/.ssh/id_rsa.pub ~/ ), then click the same button, it should be "update key", after that, you public is uploaded successfully.

3. Upload your repository

I refer to this link, you need to:

  1. Create a repository in bitbucket
  2. Note the URL you should use is: git@bitbucket.org:youruser/yourepo.git
  3. in console, go to your locale repository: $cd /path/to/my/repo
  4. git push --mirror git@bitbucket.org:youruser/progbuenos.git

Then the local code will be uploaded to bitbucket, you can use git clone to fetch it back