PDA

View Full Version : Need some Help w/ Xcode - Objective-c - I'm new at this




jjardim
Mar 19, 2008, 06:03 PM
I've been trying to understand the GUI of Xcode, and Interface builder along w/ learning C. I've made good progress learning, things are clicking here and there but I don't understand the standard methods for a class.

Example
I have added an NSTextView object to my .nib file, then added an NSTextField as well. I also added 2 push buttons (NSButton) and linked them up to display text when clicking on the button. But it to display text I could not use the same method.

On the NSTextView I had to use [textView setString: @"Hello World"];
On the NSTextField I had to use ..
[words setStringValue:@"Hello, World"];
[words setNeedsDisplay:YES];

How can I find out with out searching the internet how to accomplish stuff like this. From working with Visual Basic, I would just type txtField. (and after I typed . it would bring up a list and I would chose settext=) so it showed me all the associated methods with the txtField class. Is there a way for me to find this info out in Xcode?

Thanks!
Jason

just for reference here are my files
.h
#import <Cocoa/Cocoa.h>


@interface AppController : NSObject {
IBOutlet id textView;

IBOutlet NSTextField *words;
}


- (IBAction) clearText: sender;
- (IBAction) sayHello: (id)sender;

@end


********************
.m
#import "AppController.h"

@implementation AppController

- (IBAction) clearText: sender
{
[textView setString: @"Hello World "];
}

- (IBAction)sayHello:(id)sender{
[words setStringValue:@"Hello, World"];
[words setNeedsDisplay:YES];
}

@end



sord
Mar 19, 2008, 06:56 PM
Just turn auto complete on if it isn't already (in XCode's preferences). I think the shortcut to make it pop up is option escape, or something like that (not at my mac at the moment).

Eraserhead
Mar 19, 2008, 07:21 PM
From working with Visual Basic

I'm so sorry, now you get to use a framework with some thought in it :p.

Seriously now go to Help>Documentation in Xcode, check its set to API and All Doc Sets, then type the name of the class to see what it does.

If you want more VB-like behaviour enable Autocomplete in Xcode Menu>Preferences>Code Sense>Automatically Suggest