PDA

View Full Version : Splitting code into 2 parts in obj-C (newbee)




dova
Oct 31, 2009, 04:37 PM
Hello,
I am totally new in Objective-C and trying to learn this language:
I would like to split the following code into 2 parts:

MySaveMenuController.h > contains code to open OpenPanel
MySaveMenuController.m > contains code to open OpenPanel

and
DisplayTextField.h > contains code to open textField with tvarFilename after opening OpenPanel
DisplayTextField.m > contains code to open textField with tvarFilename after opening OpenPanel

How i can do this?
Thank you


MySaveMenuController.h

// MySaveMenuController.h
// Example

#import <Cocoa/Cocoa.h>


@interface MySaveMenuController : NSObject {
IBOutlet NSTextField *textField;
}
- (IBAction)doOpen:(id)pId;

@end


MySaveMenuController.m

// MySaveMenuController.m
// Example

#import "MySaveMenuController.h"

@implementation MySaveMenuController


- (IBAction)doOpen:(id)pId; {
NSLog(@"doOpen");
NSOpenPanel *tvarNSOpenPanelObj = [NSOpenPanel openPanel];
NSInteger tvarNSInteger = [tvarNSOpenPanelObj runModalForTypes:nil];
if(tvarNSInteger == NSOKButton){
NSLog(@"doOpen we have an OK button");
} else if(tvarNSInteger == NSCancelButton) {
NSLog(@"doOpen we have a Cancel button");
} else {
NSLog(@"doOpen tvarInt not equal 1 or zero = %3d",tvarNSInteger);
} // end if

NSString * tvarDirectory = [tvarNSOpenPanelObj directory];
NSLog(@"doOpen directory = %@",tvarDirectory);
NSString * tvarFilename = [tvarNSOpenPanelObj filename];
NSLog(@"doOpen filename = %@",tvarFilename);




[textField setStringValue:tvarFilename]; // this should be splitted in to the new file:


} // end doOpen

@end



xStep
Nov 1, 2009, 02:34 PM
You may want to clarify what you are trying to do. I've read your post twice over two days and still don't understand your goal.