iOS NSNumber isEqualToNumber

ChatGPT 3.5 国内中文镜像站免费使用啦

零基础 Object-C 学习路线推荐 : Object-C 学习目录 >> Object-C 基础

零基础 Object-C 学习路线推荐 : Object-C 学习目录 >> Object-C 线程

零基础 Object-C 学习路线推荐 : Object-C 学习目录 >> OpenGL ES

零基础 Object-C 学习路线推荐 : Object-C 学习目录 >> GPUImage

零基础 Object-C 学习路线推荐 : Object-C 学习目录 >> AVFoundation

零基础 Object-C 学习路线推荐 : Object-C 学习目录 >> CocoaPods


一.NSNumber isEqualToNumber 简介

/*

 If:
    a < b   then return NO. The left operand is smaller than the right operand.
    a > b   then return NO. The left operand is greater than the right operand.
    a == b  then return YES. The operands are equal.
*/

- (BOOL)isEqualToNumber:(NSNumber *)number;

二.NSNumber isEqualToNumber 实战

/******************************************************************************************/
//@Author:猿说编程
//@Blog(个人博客地址): www.codersrc.com
//@File:iOS NSNumber isEqualToNumber
//@Time:2021/09/22 08:00
//@Motto:不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!
/******************************************************************************************/

NSNumber *number1 = [NSNumber numberWithFloat:10.0];
NSNumber *number2 = [NSNumber numberWithFloat:20.0];
NSNumber *number3 = [NSNumber numberWithFloat:30.0];
NSNumber *number4 = [NSNumber numberWithFloat:30.0];
    
NSLog(@"number1 = %@ number2 = %@ number3 = %@",number1,number2,number3);
    
//number1 < number2
NSLog(@"[number1 isEqualToNumber:number2]:%d",[number1 compare:number2]);
    
//number2 > number1
NSLog(@"[number2 isEqualToNumber:number1]:%d",[number2 compare:number1]);
    
//number3 = number4
NSLog(@"[number3 isEqualToNumber:number4]:%d",[number3 compare:number4]);

/*
number1 = 10 number2 = 20 number3 = 30
[number1 isEqualToNumber:number2]:0
[number2 isEqualToNumber:number1]:0
[number3 isEqualToNumber:number4]:1
*/

三.猜你喜欢


ChatGPT 3.5 国内中文镜像站免费使用啦
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容