NSString with \n or line break

前端 未结 10 860
生来不讨喜
生来不讨喜 2020-12-04 11:15

Does anyone know how to use line breaks in NSString? I need to do something like this -

[NSString stringWithFormat:@\"%@,\\n%@\", mystring1,mystring2];
         


        
10条回答
  •  盖世英雄少女心
    2020-12-04 11:51

    I just ran into the same issue when overloading -description for a subclass of NSObject. In this situation I was able to use carriage return (\r) instead of newline (\n) to create a line break.

    [NSString stringWithFormat:@"%@\r%@", mystring1,mystring2];

提交回复
热议问题