Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Program received signal: "EXC_BAD_ACCESS"

[internalExpressionaddObject:[NSNumbernumberWithDouble:operand]];


[internalExpressionaddObject:[NSStringstringWithString:operation]];


None of these work while I'm sure that both operation and operand have something in there. I've debugged it and saw that internalExpression just points to 0x0, which is obviously nil. Do I need to initialize it? Although I use NSString without initialization. Both are instance variables by the way.

Xcode-OTHER, Mac OS X (10.6.7), Xcode 4.0.1

Posted on Jun 20, 2012 5:56 AM

Reply
15 replies

Jun 20, 2012 6:02 AM in response to TheNavigator

Initializing it fixed the 0x0 thing, but I still can't solve the main issue when this method is called. The error received is the title of the discussion.


- (IBAction)evaluatePressed

{

[displaysetText:[NSStringstringWithFormat: @"%d", [CalculatorBrainevaluateExpression:[[selfbrain].expressioncopy]

usingVariableValues:[[NSDictionary alloc] initWithObjectsAndKeys:@"x", 2, @"a", 4, @"b", 8, nil]] ]];

}


Any help is appreciated. Thanks in advance.

Jun 22, 2012 2:17 AM in response to TheNavigator

Much thanks guys for your help 🙂


I'm stuck at another problem though.


NSMutableArray *evaluatingExpression = [anExpression copy];

if ( ! [[evaluatingExpression lastObject] isEqual:@"="] ) {

[evaluatingExpression addObject:@"="];

}


It crashes at [evaluatingExpression addObject:@"="]; saying "Program received signal: SIGART".


If this case is wrong, it crashes at another point.


for (NSString *variableObject in variables) {

if ([variableObject isEqualToString:character]) {

[workerBee setOperand: [[variables objectForKey:variableObject] doubleValue]];

break;

}

}


It crashes at if ([variableObject isEqualToString:character]) saying the same message.


Debug logs statement I noticed:


*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x540cc00'


How NSDictionary is declared:


- (IBAction)evaluatePressed

{

[displaysetText:[NSStringstringWithFormat: @"%g", [CalculatorBrainevaluateExpression:[[selfbrain].expressioncopy]

usingVariableValues:[[NSDictionary alloc]

initWithObjectsAndKeys:

@"x", [NSNumber numberWithDouble:2],

@"a", [NSNumber numberWithDouble:4],

@"b", [NSNumber numberWithDouble:8], nil]] ]];

}


I'm pulling out my hair because of those errors..


Any help is appreciated, and thanks for those who helped me at the first error again.

Jun 23, 2012 7:21 PM in response to etresoft

Just noticed that I flipped the order of keys and objects. I flipped them and everything worked fine.


if ( ! [[evaluatingExpression lastObject] isEqual:@"="] ) {

[evaluatingExpression addObject:@"="];

}


doesn't work though 😟


2012-06-24 05:14:57.754 Calculator[1602:207] -[__NSArrayI addObject:]: unrecognized selector sent to instance 0x54017d0

2012-06-24 05:14:57.899 Calculator[1602:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI addObject:]: unrecognized selector sent to instance 0x54017d0'


evaluatingExpression is a copy of expression sent to the evaluateExpression method as an argument/parameter


Shall I use [NSString stringWithString:@"="] instead?


I can do it in an alter way getting out of adding an object way, but the main goal of solving these stuff is to know how to pass those code errors, so I need to know why it happens so if it happened one day where I must use it, I can solve it :|


Thanks again etresoft for your help 🙂


EDIT: Just tried [evaluatingExpression addObject:[NSString stringWithString:@"="] instead. Didn't work. Still the same error. I knew that there's something wrong with the method itself or evaluatingExpression object, but I just tried...


Message was edited by: TheNavigator - Added the Edit

Program received signal: "EXC_BAD_ACCESS"

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.