From 2c1b3783e41efda51a05ae748e4ec9d373209e24 Mon Sep 17 00:00:00 2001 From: "C.W. Betts" Date: Sun, 9 Feb 2014 14:52:32 -0700 Subject: [PATCH] =?UTF-8?q?Use=20for=E2=80=A6=20in=E2=80=A6=20Objective=20?= =?UTF-8?q?C=20enumeration=20where=20possible.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUAppcast.m | 19 ++++++------------- SUDSAVerifier.m | 4 +--- SUDiskImageUnarchiver.m | 4 +--- SUPipedUnarchiver.m | 4 +--- SUUnarchiver.m | 4 +--- SUUpdateAlert.m | 4 +--- SUUpdater.m | 4 +--- 7 files changed, 12 insertions(+), 31 deletions(-) diff --git a/SUAppcast.m b/SUAppcast.m index 61b2115f..7473e931 100644 --- a/SUAppcast.m +++ b/SUAppcast.m @@ -23,11 +23,11 @@ - (NSDictionary *)attributesAsDictionary { NSEnumerator *attributeEnum = [[self attributes] objectEnumerator]; - NSXMLNode *attribute; NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; - while ((attribute = [attributeEnum nextObject])) + for (NSXMLNode *attribute in attributeEnum) { [dictionary setObject:[attribute stringValue] forKey:[attribute name]]; + } return dictionary; } @end @@ -154,9 +154,7 @@ } } - NSEnumerator *nameEnum = [nodesDict keyEnumerator]; - NSString *name; - while ((name = [nameEnum nextObject])) + for (NSString *name in nodesDict) { node = [self bestNodeInNodes:[nodesDict objectForKey:name]]; if ([name isEqualToString:@"enclosure"]) @@ -177,8 +175,7 @@ { NSMutableArray *deltas = [NSMutableArray array]; NSEnumerator *childEnum = [[node children] objectEnumerator]; - NSXMLNode *child; - while ((child = [childEnum nextObject])) { + for (NSXMLNode *child in childEnum) { if ([[child name] isEqualToString:@"enclosure"]) [deltas addObject:[(NSXMLElement *)child attributesAsDictionary]]; } @@ -232,8 +229,7 @@ { [[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:nil]; } - [downloadFilename release]; - downloadFilename = nil; + self.downloadFilename = nil; [self reportError:error]; } @@ -259,13 +255,10 @@ else if ([nodes count] == 0) return nil; - NSEnumerator *nodeEnum = [nodes objectEnumerator]; - NSXMLElement *node; NSMutableArray *languages = [NSMutableArray array]; NSString *lang; NSUInteger i; - while ((node = [nodeEnum nextObject])) - { + for (NSXMLElement *node in nodes) { lang = [[node attributeForName:@"xml:lang"] stringValue]; [languages addObject:(lang ? lang : @"")]; } diff --git a/SUDSAVerifier.m b/SUDSAVerifier.m index eb4dd2ff..8e798434 100644 --- a/SUDSAVerifier.m +++ b/SUDSAVerifier.m @@ -145,10 +145,8 @@ static NSData *rawKeyData( NSString *key ) // Remove whitespace around each line of the key. NSMutableArray *pkeyTrimmedLines = [NSMutableArray array]; - NSEnumerator *pkeyLinesEnumerator = [[t componentsSeparatedByString:@"\n"] objectEnumerator]; NSCharacterSet *whiteSet = [NSCharacterSet whitespaceCharacterSet]; - NSString *pkeyLine; - while ((pkeyLine = [pkeyLinesEnumerator nextObject]) != nil) + for (NSString *pkeyLine in [t componentsSeparatedByString:@"\n"]) { [pkeyTrimmedLines addObject:[pkeyLine stringByTrimmingCharactersInSet:whiteSet]]; } diff --git a/SUDiskImageUnarchiver.m b/SUDiskImageUnarchiver.m index 8fb70361..8e67749a 100644 --- a/SUDiskImageUnarchiver.m +++ b/SUDiskImageUnarchiver.m @@ -119,9 +119,7 @@ goto reportError; } - NSEnumerator *contentsEnumerator = [contents objectEnumerator]; - NSString *item; - while ((item = [contentsEnumerator nextObject])) + for (NSString *item in contents) { NSString *fromPath = [mountPoint stringByAppendingPathComponent:item]; NSString *toPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item]; diff --git a/SUPipedUnarchiver.m b/SUPipedUnarchiver.m index 3c0a6c31..705d7de4 100644 --- a/SUPipedUnarchiver.m +++ b/SUPipedUnarchiver.m @@ -22,9 +22,7 @@ @"extractTBZ", @".tar.bz2", @"extractTBZ", @".tbz", nil] retain]; NSString *lastPathComponent = [path lastPathComponent]; - NSEnumerator *typeEnumerator = [typeSelectorDictionary keyEnumerator]; - id currentType; - while ((currentType = [typeEnumerator nextObject])) + for (id currentType in typeSelectorDictionary) { if ([currentType length] > [lastPathComponent length]) continue; if ([[lastPathComponent substringFromIndex:[lastPathComponent length] - [currentType length]] isEqualToString:currentType]) diff --git a/SUUnarchiver.m b/SUUnarchiver.m index 3073b63b..47ff5fa2 100644 --- a/SUUnarchiver.m +++ b/SUUnarchiver.m @@ -20,9 +20,7 @@ + (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host { - NSEnumerator *implementationEnumerator = [[self unarchiverImplementations] objectEnumerator]; - id current; - while ((current = [implementationEnumerator nextObject])) + for (id current in [self unarchiverImplementations]) { if ([current canUnarchivePath:path]) return [[[current alloc] initWithPath:path host:host] autorelease]; diff --git a/SUUpdateAlert.m b/SUUpdateAlert.m index c35f4e13..9ccf21a4 100644 --- a/SUUpdateAlert.m +++ b/SUUpdateAlert.m @@ -330,9 +330,7 @@ if (webViewMenuItems) { - NSEnumerator *itemEnumerator = [defaultMenuItems objectEnumerator]; - NSMenuItem *menuItem = nil; - while ((menuItem = [itemEnumerator nextObject])) + for (NSMenuItem *menuItem in defaultMenuItems) { NSInteger tag = [menuItem tag]; diff --git a/SUUpdater.m b/SUUpdater.m index 29aaacf3..334e2c33 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -503,9 +503,7 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault // Build up the parameterized URL. NSMutableArray *parameterStrings = [NSMutableArray array]; - NSEnumerator *profileInfoEnumerator = [parameters objectEnumerator]; - NSDictionary *currentProfileInfo; - while ((currentProfileInfo = [profileInfoEnumerator nextObject])) + for (NSDictionary *currentProfileInfo in parameters) [parameterStrings addObject:[NSString stringWithFormat:@"%@=%@", [[[currentProfileInfo objectForKey:@"key"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [[[currentProfileInfo objectForKey:@"value"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]; NSString *separatorCharacter = @"?";