• 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
Re: NSArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray


  • Subject: Re: NSArray
  • From: Markus Spoettl <email@hidden>
  • Date: Sun, 1 Jun 2008 17:21:30 -0700

On Jun 1, 2008, at 5:02 PM, Nathan wrote:
int x;
- (IBAction)addNew:(id)sender {
	NSString *temp = @"Enter Todo Item Here";
   [Items addObject: temp];
	x=[Items count];
	[label setIntValue: x];
	[tableView setDataSource: Items];
	[tableView reloadData];
}

"Items" is a mutable array. "label" is a label for debugging. "tableView" is a tableview. When addNew is called, I want an object with the value of temp added to array "items". Then the tableView needs updating, so that it is displaying all items in the array. The code runs, I know my connections are good, but nothing happens. So I added the label who's connection I also know is good to make sure the items are getting added to the array and they aren't. When the button is pressed, no matter how many times, label always equals zero. What's wrong?

Not sure without seeing the rest of your code but if Items is nil that would cause exactly the behavior your are seeing. You can message nil objects (will will not cause a crash) and the return values will basically be some form of 0 (depending on the return type of methods), so [Items count] will return zero.


Are you initializing Items at some point? It should be something like: "Items = [[NSMutableArray] alloc] init];".

Regards
Markus
--
__________________________________________
Markus Spoettl

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >NSArray (From: Nathan <email@hidden>)

  • Prev by Date: Re: Hiding NSImageView
  • Next by Date: Re: NSArray
  • Previous by thread: NSArray
  • Next by thread: Re: NSArray
  • Index(es):
    • Date
    • Thread