• 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: Error, but why?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error, but why?


  • Subject: Re: Error, but why?
  • From: Andrew Pinski <email@hidden>
  • Date: Fri, 2 Nov 2001 11:44:30 -0500

On Friday, November 2, 2001, at 11:23 , email@hidden wrote:

So, I'm following along with this example for a Foundation Tool from a book due in December. Here is the code for main.m, which builds without error:

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
NSMutableArray *array;
int i;
NSNumber *number;

NSAutoreleasePool *pool = [ [NSAutoreleasePool alloc] init];

array = [ [NSMutableArray alloc] init];
for ( i = 0; i < 10; i++ )
{
number = [ [NSNumber alloc] init];
^^^^ this line needs to be
number = [NSNumber numberWithInt:i];
otherwise you get an null value which cannot be added to an Array.
[array addObject: number];
}

NSLog(@"array = %@", array);
[array release];
[pool release];
return 0;
}
//end code

However, when I build and run (hammer & monitor icon) I get an "Error from Executable Runner" message:

2001-11-02 11:07:18.489 lottery[563] *** Uncaught exception: <NSInvalidArgumentException> *** -[NSCFArray addObject:]: attempt to insert nil

lottery has exited with status 255.
//end error message

I'm supposed to get something like:

2001-11-02 11:07:18.489 lottery[563] array = (0, 1, 2, . . .9)
lottery has exited with status 0.

So, can anyone give me a clue or explanation as to what's going on? This code was originally written some months ago with OS X 10.0.x and related tools. I'm now on 10.1--OS & Tools. Did I miss something in the release notes? Thank, as always.

Brian E. Howard
Cocoa Cult Central
tooling along, slowly


References: 
 >Error, but why? (From: email@hidden)

  • Prev by Date: Error, but why?
  • Next by Date: Re: Error, but why?
  • Previous by thread: Error, but why?
  • Next by thread: Re: Error, but why?
  • Index(es):
    • Date
    • Thread