zoukankan      html  css  js  c++  java
  • iOS 开发 OC编程 属性和字符串练习

       文艺青年改成“213青年

    //    整数123 转换为字符串“123”

    //    “i love you”单词首字母变大写 “I love You”

    //    截取字符串“20|http://www.baidu.com “|” 前面和后面的字符串,并输出。提示:-componentsSeparatedByString:

        //1

        //定义成不可变字符串

    //    NSString *strVal = @"文艺青年";

    //   strVal = [strVal stringByReplacingOccurrencesOfString:@"文艺" withString:@"213"];

    //   NSLog(@"%@",strVal);

        //定义成可变字符串

    //    NSMutableString * strval1 = [NSMutableString stringWithFormat:@"文艺青年"];

    //    NSString *p = [strval1 stringByReplacingOccurrencesOfString:@"文艺" withString:@"213"];

    //    NSLog(@"%@", p);

       

        //2

        int a = 123;

        NSString *str = [NSString stringWithFormat:@"%d",a];

        NSLog(@"%@", str);

        //3

        NSString *b = @"i lOve you";

      //  NSString *c = [b uppercaseString];

        NSString *c =[b capitalizedString];

        NSLog(@"%@", c);

        //5

        NSString *str1 = @"20|http://www.baidu.com";

        NSArray *str2 =[str1 componentsSeparatedByString:@"|"];

        for (NSString *b in str2) {

            NSLog(@"%@", b );

        }

  • 相关阅读:
    第一课 进阶高手的大门
    Codeforces Round #363 (Div. 2) C. Vacations
    HDU 5718 Oracle
    A
    Fibonacci数的后9位
    UESTC 982质因子分解
    UESTC149 解救小Q
    UESTC93 King's Sanctuary
    HDU 4857 逃生
    L1-006. 连续因子
  • 原文地址:https://www.cnblogs.com/yuhaojishuboke/p/5043123.html
Copyright © 2011-2022 走看看