Jude Michael Murphy
Jude Michael Murphy

Reputation: 1198

EXC_ARITHMETIC Error in Xcode

if (([gameplay1.text intValue] % [gameplay3.text intValue]) == 0)
{
    //Do something
}

Can someone please help me out with this?

Upvotes: 0

Views: 3251

Answers (3)

user2564144
user2564144

Reputation: 11

it because you can't divide by zero

you can add some code like

if(![gameplay3.text intValue]){
    gameplay3.text = "1";
}

before your if judgement

it should be work and not affect your results :)

Upvotes: 1

user529758
user529758

Reputation:

You have provided almost no information, but it seems to me that

[gameplay3.text intValue]

returns 0. You can't divide by zero, hence the error.

Upvotes: 7

Spencer Uresk
Spencer Uresk

Reputation: 3710

There are a few things that can cause this, the most likely of which being that you are trying to divide by 0. What is the value of [gameplay3.text intValue] when this occurs?

Upvotes: 2

Related Questions