Question

I've got a rather interesting problem. I'm writing a chess engine using bitboards for iOS 7 which I want to work on the iPhone 4, 4s, 5, and 5s. Up till now I was doing all my testing in the iOS 64bit iPhone simulator, but I decided to run it on my phone and all of the black chess pieces were missing. I quickly figured out that this was because my iPhone is an iPhone 5 and I think it is having some issues with bitwise operations on 64bit numbers. Are there any workarounds I can use to get this app to work on the iPhone 4, 4s, and 5? Or do I have to make this iPhone 5s-only? It would be rather frustrating if that were the case.

Update: After further investigation I have determined the problem to be that, while all of my explicitly stated types are unsigned long long integers, because I store collections of them in nsarrays as object literals, when I call integerValue after calling objectForKey, this returns an NSInteger. However, on 32bit phones, NSInteger is 32bits when I need 64. Is there a way to store and retrieve 64 bit integers in and from an NSArray?

No correct solution

OTHER TIPS

Okay, I finally figured out what was going on. I had been storing collections of bitboards as nsnumbers in nsarrays and using integerValue to get them out. This worked fine on 64bit devices because integerValue returns an nsinteger which is a 32 or 64 bit integer based on the processor. Once I changed all of the function calls to unsignedLongLongValue it worked like a charm.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top