PDA

View Full Version : New to Xcode, small problem




JimmyFeatures
Oct 31, 2005, 03:19 PM
I've just started using Xcode, after spending quite sometime using C/C++, and I have a small problem. I have a small program where the user must input text in to a text field, and I want to assign that string to a variable. I have all the outlets and actions set up, I just need to know the syntax of the code.

For example, the outlet that the text field is connected to is called 'input' and I wish to assign that to the variable 'name'.

Thanks.



cbiffle
Oct 31, 2005, 03:58 PM
For example, the outlet that the text field is connected to is called 'input' and I wish to assign that to the variable 'name'.

NSString *name = [input stringValue]; ?

I include the question mark because you didn't specify what language you were writing in (C, Objective-C, C++), what libraries you were using (Carbon, Cocoa, or Java), etc.

If you're using ObjC and Cocoa (which is what I'd recommend), I'd bookmark Apple's docs on the Application Kit and Foundation Kit. You can find most of this information there, or in the tutorials/howtos they link to.

JimmyFeatures
Oct 31, 2005, 04:29 PM
Thanks, that completely sorted me out.

And yes, I'm using objective C and cocoa.