0
4

2 回答 2

1

stringWithFormat is "just" a front-end to sprintf; as it's plain C, scanf and its variants are also available if you need.

于 2012-10-09T11:21:17.610 回答
0

你描述你的parseWithFormat功能的方式,由于结构模糊,它不能工作。

格式替换的%@标记在您的结果字符串中消失了string,因此结果提取可能不明确。

示例

NSString *format = @"He likes %@ and %@.";
NSString *string = [NSString 
   stringWithFormat:format, @"apples and oranges", @"bananas"];
// --> @"He likes apples and oranges and bananas."
NSArray *array = [string parseWithFormat:format];
// Array could be:
// @[@"apples and oranges", @"bananas"] or 
// @[@"apples"  @"oranges and bananas"]
于 2012-10-09T12:30:01.907 回答