mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
Use for… in… Objective C enumeration where possible.
This commit is contained in:
1 parent
808bde2699
commit
2c1b3783e4
7 files changed
+12
-31
No files matched your search
+6
-13
@@ -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 : @"")];
|
||||
}
|
||||
|
||||
+1
-3
@@ -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]];
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
|
||||
+1
-3
@@ -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])
|
||||
|
||||
+1
-3
@@ -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];
|
||||
|
||||
+1
-3
@@ -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];
|
||||
|
||||
|
||||
+1
-3
@@ -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 = @"?";
|
||||
|
||||
Reference in new issue
Block a user