iOS开发(OC)-字符串反序

2016-11-02  本文已影响38人  Fire_day
    NSString * str = @"i love you";
    NSMutableString * reverseString = [NSMutableString string];
    for(int i = 0 ; i < str.length; i ++){
        //倒序读取字符并且存到可变数组数组中
        unichar c = [str characterAtIndex:str.length- i -1];
        [reverseString appendFormat:@"%c",c];
    }
    str = reverseString;
上一篇下一篇

猜你喜欢

热点阅读