Splitting code into 2 parts in obj-C (newbee)

Discussion in 'Mac Programming' started by dova, Oct 31, 2009.

  1. macrumors newbie

    #1
    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
    PHP:
    //  MySaveMenuController.h
    //  Example

    #import <Cocoa/Cocoa.h>


    @interface  MySaveMenuController NSObject {
        
    IBOutlet NSTextField *textField;

    - (
    IBAction)doOpen:(id)pId;

    @
    end
    MySaveMenuController.m
    PHP:
    //  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
     
  2. macrumors 68000

    #2
    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.
     

Share This Page