首页 > 代码库 > Object C (2) --- NSString的创建

Object C (2) --- NSString的创建

        NSString *str1 = @"a string";

        NSString *str2 = [[NSString alloc] init];

        str2 = @"a string";

        [str2 release];

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

        [str3 release];

        NSString *str4 = [NSString stringWithString:@"a string"];

        [str4 release];

        NSString *str5 = [[NSString alloc] initWithUTF8String:"a string"];

        [str5 release];

        NSString *str6 = [NSString stringWithUTF8String:"a string"];

        NSString *str7 = [NSString stringWithFormat:@"a string %d", 5];

        NSLog(@"%@",str7);