Useful code for me when I use cocoa framework