Why is my NSMutableArray returning nill?

Posted by lampShade on Stack Overflow See other posts from Stack Overflow or by lampShade
Published on 2010-04-13T20:46:18Z Indexed on 2010/04/13 21:13 UTC
Read the original article Hit count: 404

Filed under:
|

I have a very simple task: add the contents of a textField to an NSMutableArray.The Problem is the array is returning nill. I believe that it has something to do with the fact that the array I'm using is declared as an instance variable.

/*
 IBOutlet NSTextField *textField;
 IBOutlet NSTabView *tableView;
 IBOutlet NSButton *button;
 NSMutableArray *myArray;
 */

#import "AppController.h"


@implementation AppController


-(IBAction)addNewItem:(id)sender
{
    NSString *string = [textField stringValue];
    NSLog(@"%@",string);

    [myArray addObject:string];
    NSLog(@"%d",[myArray count]);//this outputs 0 why is that?

}

© Stack Overflow or respective owner

Related posts about cocoa

Related posts about beginner