OC_04_03

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        
        //可变字符串   NSMutableString
        NSMutableString *mString = [NSMutableString stringWithString:@"nihao"];
        NSMutableString *mString1 = [NSMutableString stringWithFormat:@"hello%d",100];
        //从本地读取文件
        NSMutableString *mString2 = [NSMutableString stringWithContentsOfFile:@"" encoding:NSUTF8StringEncoding error:nil];
        //从网络读取文件
        NSMutableString *mString3 = [NSMutableString stringWithContentsOfURL:[NSURL URLWithString:@""] encoding:NSUTF8StringEncoding error:nil];
    
        //可变字符串独特初始化方法,初始化一个空间为100的可变字符串
        NSMutableString *mString4 = [[NSMutableString alloc] initWithCapacity:100];
        
        //C语言的字符数组转成OC中的字符串
//        [[NSString alloc] initWithCharacters:<#(nonnull const unichar *)#> length:<#(NSUInteger)#>]//一般不怎么用
        
        NSMutableString *targetString = [NSMutableString stringWithString:@"呵呵,我日了

你可能感兴趣的:(OC_04_03)