views:

28

answers:

2

Hi Everyone,

I'm a beginner at Objective-C and am trying to initialize an NSMutableArray with objects of various types. Here is my code:

 NSMutableArray *mutArr = [NSMutableArray arrayWithCapacity:1];
 [mutArr addObject:path];
 [mutArr addObject:fullPath];
 [mutArr addObject:pathArray];
 [mutArr addObject:pI];
 [mutArr addObject:processName];
 [mutArr addObject:processIdentifier];
 [mutArr addObject:dictionary];

 NSLog(@"I am past the initialization of mutArr.");

My code doesn't reach the NSLog statement, and I'm getting an error on the Debug Console of XCode saying, "The Debugger has exited due to signal 10 (SIGBUS)." I don't know what this means, why it's happening, or how to fix it. Could someone please help me?

Thank you!!

A: 

Try using

NSMutableArray *mutArr = [[NSMutableArray alloc] initWithObjects:nil];

and then the rest of your code. That should work :-)

Erle
A: 

Hi Carl and Erle, Yes, I figured out the problem just a few minutes ago. My variable processIdentifer was not defined correctly. I was using the declaration NSNumber *processIdentifier = (NSNumber *)[pI processIdentifier]; rather than NSNumber *processIdentifier = [NSNumber numberWithInt:[pI processIdentifier]]; so I was getting an error during the initialization of my mutable array. Thanks for the advice!!

NoobjectiveC