NSTextField content

Discussion in 'Mac Programming' started by Arne, Jan 24, 2007.

  1. Arne macrumors regular

    May 14, 2006

    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!

  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    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.
  3. whooleytoo macrumors 604


    Aug 2, 2002
    Cork, Ireland.
    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.

Share This Page