How to append a NSMutableString with a NSMutableString?

后端 未结 4 1584
生来不讨喜
生来不讨喜 2020-12-19 00:43
NSMutableString *str, *str1;

//allocation here

i am using [str appendString:str1] is not working. [str appendFormat:str

4条回答
  •  忘掉有多难
    2020-12-19 01:21

    if str == nil, no call are performed because there is no object allocated to receive the message but no exception are raised (messages sent to nil return nil by design in Objective-C).

    NSMutableString *str, *str1;
    
    str = [NSMutableString stringWithString:@"Hello "];
    str1 = [NSMutableString stringWithString:@"World"]; 
    
    NSMutableString *sayit = [str appendString:str1];
    

提交回复
热议问题