Xcode – NSTextField populate Tool Tip

I was doing some experimentation this week. Someone recommended a feature in my soon to be released disc image dictionary attack tool.  

I display the file path in an NSTextField.  And it is possible that path could end up longer than the field displays.   So they recommended I populate the Tool Tip popup with the contents of the text field.

I found that took two things in my case.

First I had to make the Tool Tip populate when a user selected the file from the open dialog box. That is easy enough.  We just call setToolTip method for the TextField. 

[projectPathField setToolTip:[self filePath]];

Now the tricky part.  That sets the tool tip when I first get the filePath.  But now if the field is editable you want the tool tip to keep up with the contents of the field.  I added the following method with one line of code to my AppController class.  Then I just made sure to set my AppController object as Delegate of the NSTextField in Interface Builder.  Now the tool tip stays in sync as someone types in the text field.


– (void)controlTextDidChange:(NSNotification *)aNotification


[[aNotification object] setToolTip:[[aNotification object] stringValue]];



Xcode – Organization Name in Code Header

I did find out something at the Big Nerd Ranch interesting.  Xcode does not always pick up your company name properly from your address book entry.  It should pick up your name, company etc and fill in the standard header and copyright info as you make new source code files.   But it fails a lot of the time.

So here is how you fix it to show your organizational name for good.

Open up terminal.  Replace the word ORGNAME with whatever you want to show for who the code is copyrighted to.  This is all one line to enter into the terminal prompt.  It is going to simply edit a plist preference value setting.  Nothing major.

defaults write com.apple.xcode PBXCustomTemplateMacroDefinitions ‘{ ORGANIZATIONNAME = “ORGNAME”;}’

Xcode v3

Last night I decided my discretionary time would be spent on starting with xcode to get started toward my bootcamp in October.  The more I learn before then the more I will get out of the camp.  I was using Aaron Hillegass’ Second Edition Cocoa book.  Of course Apple had to change how you create and associate classes to objects in the GUI builder.  I found once I went through Apple’s own tutorial example that I was able to automatically adapt the process in the book to how xcode v3 works.   Was pretty fun once I got it straight in my head.  There is still so much to learn and I doubt I will ever be up to a professional programmer level.  I am just hoping to get proficient enough to make some ideas I have had.  Making a few cocoa front ends for some good security tools would be cool too.I want to get all the way through this second edition book.  Then the couple of others I have.  Aaron’s third edition is coming out sometime soon.  Likely, I will get that and go through it once before October.