When Int overflow causes damage to an iOS application, how can I notice it

My application needs to use intto make multiple multiples, it is easy to multiply two fairly large numbers.

Of course, it will collapse. And how can I note some bool value. Like every time before we exit the application, we are saveDataat AppDelegate.swift:

func applicationWillTerminate(application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
0
source share
2 answers

(+, -, *,/,...) , . , . . Swift NSException, . , , nil.

, , . - - " " &+, &- &* , , (Objective-) C.

+2

NSInteger Int.

NSInteger, , , - int, 32 int, a 64 - a long.

NSInteger int/long, .

NSInteger/NSUInteger *dynamic typedef *s , :

#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
0

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


All Articles