PDA

View Full Version : NSTextField content




Arne
Jan 24, 2007, 10:30 AM
Hello,

I am new to Mac OS. I program just for personal uses and because of personal interest. I have been programming in C++ and Java for quite a while now. But Cocoa is (according to Apples decumentations) not supporting Java any more, so I will have to learn Objective-C.

I have gone threw Apples Xcode-tutorial and made the CurrencyConverter work. But now I want to write a simple program and I can't even find out how I get the text from an NSTextField. In Java it is as simple as textfield.getText(); but that doesn't seem to work and I can't find how to do it in the documentation. I guess it is being provided by some class the NSTextField implements but where is it and where can I look such things up?

Thank you for your help and sorry if I just overlooked it.

One more quetion: In NetBeans (and many other IDE's) when I for example type "object." it will give me suggestions of methods I can call (afert I hit the .). Does Xcode have such a feature?

Thanks in advance!

Arne



robbieduncan
Jan 24, 2007, 10:37 AM
You don't use . for a start. If you have an object that you have linked to a control in Interface Builder you should be able to type "[object " and it will complete a list of possible methods.

To get an NSString from an NSTextField (lets say we have NSTextField *textField) via [textField stringValue];

Edit to add: this is inherited from NSControl. In the documentation each class shows a list of the classes it inherits from making it easy to look this up.

whooleytoo
Jan 24, 2007, 10:46 AM
One more quetion: In NetBeans (and many other IDE's) when I for example type "object." it will give me suggestions of methods I can call (afert I hit the .). Does Xcode have such a feature?

Thanks in advance!

Arne

Yup, Xcode has code completion - it can either work automatically or can be invoked manually; and can either work as a pop-up list underneath, or appears 'inline'.

See the Xcode preferences to configure it how you like.