What is wrong here? (EXC_BAD_ACCESS)

My app crashes when it tries to round some numbers. What could be the problem? The debugger shows that the first line calls EXC_BAD_ACCESS.

- (NSInteger) hebrewCalanderEndDay:(NSInteger)year{

NSInteger monthsElapsed = [[NSNumber numberWithLongLong:floor((235*year-234)/19.0)]integerValue];
NSInteger partsElapsed = 12084 + 13753*monthsElapsed;
NSInteger day = 29*monthsElapsed + [[NSNumber numberWithLongLong:floor(partsElapsed/25920)] integerValue];

if(((3 * (day+1))%7 <3){
  day++;
} 
return day;
}
+3
source share
1 answer

Well, the first thing I see is the type mismatch between floor()and +numberWithLongLong:. Didn't the compiler complain about it?

Are you trying to implement a Hebrew calendar yourself? I thought CFLocale already supported it.

+1
source

Source: https://habr.com/ru/post/1786830/


All Articles