In "Beginning RandomItems" section, seeing exit code -1


#1

I’ve typed in the code as specified by the book, and the log output is appearing exactly the same as Figure 2.8 except for the exit code. For some reason my program is exiting with exit code -1, and not exit code 0 (as Figure 2.8 shows). I’m not sure if this is significant or not (I was under the impression that only positive exit codes represent actual errors in Unix), but I was hoping someone might know why I’m seeing this differing behavior?

My Code:

[code]#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

@autoreleasepool {
    
    // Create a mutable array object, store its address in items variable
    NSMutableArray *items = [[NSMutableArray alloc] init];
    
    // Send the message addObject: to the NSMutableArray pointed to
    // by the variable items, passing a string each time
    [items addObject:@"One"];
    [items addObject:@"Two"];
    [items addObject:@"Three"];
    
    // Send another message, insertObject:atIndex:, to that same array object
    [items insertObject:@"Zero" atIndex:0];
    
    // For every item in the items array...
    for (NSString *item in items) {
        // Log the description in item
        NSLog(@"%@", item);
    }
    
    // Destroy the mutable array object
    items = nil;
}

return 0;

}[/code]

Produces output like this:

[quote]2014-04-08 09:29:54.124 RandomItems[1770:303] Zero
2014-04-08 09:29:54.129 RandomItems[1770:303] One
2014-04-08 09:29:54.130 RandomItems[1770:303] Two
2014-04-08 09:29:54.131 RandomItems[1770:303] Three
Program ended with exit code: -1[/quote]


#2

That’s a new one on me.

In fact, when I TRIED to return -1, the msg at the end of the output was:

[quote]Program ended with exit code: 255
[/quote]
The best that I can suggest is to fire up the Console (Spotlight is easiest to search for this), and see if there’s any explanation there.