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

Error, but why?


  • Subject: Error, but why?
  • From: email@hidden
  • Date: Fri, 2 Nov 2001 11:23:07 -0500

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];
[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


  • Follow-Ups:
    • Re: Error, but why?
      • From: Chris Boot <email@hidden>
    • Re: Error, but why?
      • From: John Hörnkvist <email@hidden>
    • Re: Error, but why?
      • From: Andrew Pinski <email@hidden>
  • Prev by Date: Re: Book
  • Next by Date: Re: Error, but why?
  • Previous by thread: Re: How to cancel a NSURL action
  • Next by thread: Re: Error, but why?
  • Index(es):
    • Date
    • Thread