@@ -14,10 +14,11 @@ #include #import "OFArray.h" #import "OFDataArray.h" #import "OFString.h" +#import "OFAutoreleasePool.h" #import "OFExceptions.h" #import "macros.h" @implementation OFArray + array @@ -272,10 +273,11 @@ toIndex: range.start + range.length]; } - (OFString*)componentsJoinedByString: (OFString*)separator { + OFAutoreleasePool *pool; OFString *str; OFString **objs = [array cArray]; size_t i, count = [array count]; Class cls; IMP append; @@ -287,19 +289,25 @@ str = [OFMutableString string]; cls = [OFString class]; append = [str methodForSelector: @selector(appendString:)]; + pool = [[OFAutoreleasePool alloc] init]; + for (i = 0; i < count - 1; i++) { if (![objs[i] isKindOfClass: cls]) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; - append(str, @selector(appendString:), objs[i]); + append(str, @selector(appendString:), [objs[i] description]); append(str, @selector(appendString:), separator); + + [pool releaseObjects]; } append(str, @selector(appendString:), objs[i]); + + [pool release]; return str; } - (BOOL)isEqual: (id)obj @@ -345,10 +353,21 @@ OF_HASH_FINALIZE(hash); return hash; } + +- (OFString*)description +{ + OFMutableString *ret; + + ret = (OFMutableString*)[self componentsJoinedByString: @", "]; + [ret prependString: @"("]; + [ret appendString: @")"]; + + return ret; +} - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count_ {