zoukankan      html  css  js  c++  java
  • 比较两个字符串大小

    #import <Foundation/Foundation.h>

    int main(int argc, const char * argv[]) {

        @autoreleasepool {

       //比较两个字符串大小

    NSString *str=[[NSString alloc]initWithString:@"a"];

    NSString *str1=[[NSString alloc]initWithString:@"A"];

            

           NSComparisonResult  result= [str compare:str1];

           // NSComparisonResult  result= [str caseInsensitiveCompare:str1];

            if (result==NSOrderedAscending) {

                NSLog(@"str<str1");

            }else if (result==NSOrderedDescending){

                

                NSLog(@"str>str1");

            }else{

                NSLog(@"str=str1");

            }

            

            

            

            

            /*2.比较两个字符串内容是否相同

            if (str==str1) {

                

                NSLog(@"两个字符串内容相同");

            }else{

               NSLog(@"两个字符串内容不相同");

            }

            */

        /*    //1.比较字符串对象是否相同

            if ([str isEqualToString:str1]){

                

                NSLog(@"两个字符串相同");

                

            }else{

            

                NSLog(@"两个字符串不相同");

            

            }

                */

                }

        return 0;

    }

  • 相关阅读:
    ubuntu
    ubuntu
    ubuntu14.04,安装Gnome 15.10 (桌面)
    ubuntu14.04,安装Gnome 15.10 (桌面)
    Ubuntu 14.04.3 LTS如何安装谷歌输入法
    Ubuntu 14.04.3 LTS如何安装谷歌输入法
    ubuntu 安装 删除 卸载 Deb 包文件
    失去爆破音规律
    单词发音规律
    英式音标和美式音标的差异
  • 原文地址:https://www.cnblogs.com/jidezhi/p/5120702.html
Copyright © 2011-2022 走看看