Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Objective-C 中创建带有空格和所需长度的字符串的最短方法是什么?
我可以使用for循环来做到这一点,但它是几行代码。
for
返回前六个字符
NSString *fullName = @"Warif Akhand Rishi"; NSString *subString = [fullName substringToIndex:6];
你看过stringWithFormat吗?
[NSMutableString stringWithFormat:@"%20d", 42];