• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Strange NSArray problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Strange NSArray problem


  • Subject: Strange NSArray problem
  • From: Iain Delaney <email@hidden>
  • Date: Mon, 20 Jun 2005 19:06:12 -0400

I'm at my wit's end about this one, so I would appreciate any help or suggestions anyone can give.
I need an array of NSStrings to keep track of the different colors I'm using in my program.
I've declared the array as:
NSArray *myColors;
in the header for my controller class.
In the (id)init method of my controller class, I initialize the array, like this:
myColors = [NSArray arrayWithObjects: @"Blue", @"Red", @"Yellow", @"Green", nil];
Then I check the size of the array,
NSLog(@"Number of Colors: %d",[myColors count]);
And when I run it I see: "Number of Colors: 4". So far so good.


However, when I actually go to use the array in a button handler, it's gone. The button handler is a regular -(IBAction)buttonClick:(id) sender method, and I've changed the code so that all it does is log the count of the array, just like before:

NSLog(@"Number of Colors: %d",[myColors count]);
This time, though, the Run Log window says "[NSWorkspace count]: selector not recognized".


Some further information: When I go in and look with the debugger, myColors shows up with "4 objects" in the init method.
In the buttonClick method, the debugger window shows "{(int)[$VAR count]} objects".


I've removed every reference to myColors, except the initialization line and the NSLog statements, and I'm not using NSWorkspace anywhere in my code, so I don't know what's going on.

Can anyone help me with this?

Thanks,
Iain
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Strange NSArray problem
      • From: John Stiles <email@hidden>
  • Prev by Date: Re: How to trap for the delete key in NSOutlineView?
  • Next by Date: Re: How to trap for the delete key in NSOutlineView?
  • Previous by thread: Re: objectInXXXAtIndex: exception
  • Next by thread: Re: Strange NSArray problem
  • Index(es):
    • Date
    • Thread