forked from kiwi-bdd/Kiwi
-
Notifications
You must be signed in to change notification settings - Fork 55
/
KWFormatter.m
38 lines (28 loc) · 960 Bytes
/
KWFormatter.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// Licensed under the terms in License.txt
//
// Copyright 2010 Allen Ding. All rights reserved.
//
#import "KWFormatter.h"
@implementation KWFormatter
#pragma mark -
#pragma mark Getting Descriptions
+ (NSString *)formatObject:(id)anObject {
if ([anObject isKindOfClass:[NSString class]])
return [NSString stringWithFormat:@"\"%@\"", anObject];
if ([anObject conformsToProtocol:@protocol(NSFastEnumeration)]) {
NSMutableString *description = [[[NSMutableString alloc] initWithString:@"("] autorelease];
NSUInteger index = 0;
for (id object in anObject) {
if (index == 0)
[description appendFormat:@"%@", [self formatObject:object]];
else
[description appendFormat:@", %@", [self formatObject:object]];
++index;
}
[description appendString:@")"];
return description;
}
return [anObject description];
}
@end