I am trying to get the state of a menu item, whether it is checked or not. In 
my class, I wrote the very simple code to get the state of the menu item, and 
switch it to the other state when selected. All is OK with that.
In another function (in the same class) that is called from my main class, I 
can't get the state of the menu item. The .h file is imported into the main 
class, and all the code works except it just doesn't want to recognize the 
state.
I thought since the menu check on/off code block works OK and the menu item is 
recognized, that another function in the same class would be able to "see" the 
same IB object and read it's state. Obviously I'm missing something. Still a 
newb.
Thanks!
Chris

---------.h
#import <Cocoa/Cocoa.h>

@interface MyArray : NSObject {
        NSArray *myPrefs;
        NSArray *myPrefsSaved;
        IBOutlet id msEntOnOff; //THE MENU ITEM
}

- (id)makeMyPrefs;
- (id)makeMyPrefsSaved;
-(IBAction)selectMenu:(id)sender; //TOGGLES MENU CHECKMARK ON-OFF

@end

-------.m
#import "MyArray.h"

@implementation MyArray
//MAKE MY PREFS CALLED FROM ANOTHER CLASS METHOD
- (id)makeMyPrefs
{
        NSString *string1  = @"Library/Preferences/Adobe Photoshop CS3 
Settings";
        NSString *string2  = @"Library/Preferences/Adobe Illustrator CS3 
Settings";
        NSString *string3  = @"Library/Preferences/Adobe InDesign/Version 5.0";
        NSString *string4  = @"Library/Preferences/CDFinder Preferences";
        NSString *string5  = @"Library/Application Support/Firefox";
        NSString *string6  = @"Library/Safari";
        NSString *string7  = @"Library/Application Support/Adobe/Adobe 
PDF/Settings";
        NSString *string8  = @"Library/Preferences/Acrobat Distiller Prefs";
        NSString *string9  = @"Documents/Microsoft User Data";

//THIS IF STATEMENT DOES NOT WORK
        if ([msEntOnOff state]) {
                //if checkbox for menu item is on then make all items, else 
skip MSEnt
                myPrefs = [NSArray arrayWithObjects: string1, string2, string3, 
string4, string5, string6, string7, string8, string9, nil];
                NSLog(@"made arry with MS Ent");
        }
        else {
                myPrefs = [NSArray arrayWithObjects: string1, string2, string3, 
string4, string5, string6, string7, string8, nil];
                NSLog(@"made arry withOUT MS Ent");
        }
return myPrefs;
}

//code below works fine
-(IBAction)selectMenu:(id)sender{
        
        if ([msEntOnOff state]) {
                [msEntOnOff setState:0];
                NSLog(@"setting to off");
        }
        else {
                [msEntOnOff setState:1];
                NSLog(@"setting to on");
        }
}

- (void)dealloc
{
//NSLog(@"dealloc myarray");
[super dealloc];
}
@end
-------------


      

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to