From: <ho...@us...> - 2008-10-15 11:57:50
|
Revision: 13727 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=13727&view=rev Author: hofman Date: 2008-10-15 11:57:48 +0000 (Wed, 15 Oct 2008) Log Message: ----------- simplify code generating string representations Modified Paths: -------------- trunk/bibdesk/BibDocument.m Modified: trunk/bibdesk/BibDocument.m =================================================================== --- trunk/bibdesk/BibDocument.m 2008-10-14 21:55:33 UTC (rev 13726) +++ trunk/bibdesk/BibDocument.m 2008-10-15 11:57:48 UTC (rev 13727) @@ -2060,42 +2060,18 @@ } - (NSString *)RISStringForPublications:(NSArray *)items{ - NSMutableString *s = [NSMutableString string]; - NSEnumerator *e = [items objectEnumerator]; - BibItem *pub; - - while(pub = [e nextObject]){ - [s appendString:@"\n"]; - [s appendString:[pub RISStringValue]]; - [s appendString:@"\n"]; - } - - return s; + return [[items valueForKey:@"RISStringValue"] componentsJoinedByString:@"\n\n"]; } - (NSString *)citeStringForPublications:(NSArray *)items citeString:(NSString *)citeString{ OFPreferenceWrapper *sud = [OFPreferenceWrapper sharedPreferenceWrapper]; - BOOL prependTilde = [sud boolForKey:BDSKCitePrependTildeKey]; - NSString *startCite = [NSString stringWithFormat:@"%@\\%@%@", (prependTilde? @"~" : @""), citeString, [sud stringForKey:BDSKCiteStartBracketKey]]; + NSString *startCite = [NSString stringWithFormat:@"%@\\%@%@", ([sud boolForKey:BDSKCitePrependTildeKey] ? @"~" : @""), citeString, [sud stringForKey:BDSKCiteStartBracketKey]]; NSString *endCite = [sud stringForKey:BDSKCiteEndBracketKey]; - NSMutableString *s = [NSMutableString stringWithString:startCite]; - - BOOL sep = [sud boolForKey:BDSKSeparateCiteKey]; - NSString *separator = (sep)? [NSString stringWithFormat:@"%@%@", endCite, startCite] : @","; - BibItem *pub; - BOOL first = YES; + NSString *separator = [sud boolForKey:BDSKSeparateCiteKey] ? [endCite stringByAppendingString:startCite] : @","; if([items count]) NSParameterAssert([[items objectAtIndex:0] isKindOfClass:[BibItem class]]); - NSEnumerator *e = [items objectEnumerator]; - while(pub = [e nextObject]){ - if(first) first = NO; - else [s appendString:separator]; - [s appendString:[pub citeKey]]; - } - [s appendString:endCite]; - - return s; + return [NSString stringWithFormat:@"%@%@%@", startCite, [[items valueForKey:@"citeKey"] componentsJoinedByString:separator], endCite]; } #pragma mark - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |