Replaced every instance of NSEnumerator with for/in loops
parent
8d19b2538a
commit
3e057adf56
|
@ -57,9 +57,7 @@
|
||||||
[output setVolume: volume];
|
[output setVolume: volume];
|
||||||
|
|
||||||
@synchronized(chainQueue) {
|
@synchronized(chainQueue) {
|
||||||
NSEnumerator *enumerator = [chainQueue objectEnumerator];
|
for (id anObject in chainQueue)
|
||||||
id anObject;
|
|
||||||
while (anObject = [enumerator nextObject])
|
|
||||||
{
|
{
|
||||||
[anObject setShouldContinue:NO];
|
[anObject setShouldContinue:NO];
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,6 @@ escapeForLastFM(NSString *string)
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
AudioScrobblerClient *client = [[AudioScrobblerClient alloc] init];
|
AudioScrobblerClient *client = [[AudioScrobblerClient alloc] init];
|
||||||
mach_timespec_t timeout = { 5, 0 };
|
mach_timespec_t timeout = { 5, 0 };
|
||||||
NSEnumerator *enumerator = nil;
|
|
||||||
NSString *command = nil;
|
NSString *command = nil;
|
||||||
NSString *response = nil;
|
NSString *response = nil;
|
||||||
in_port_t port = 33367;
|
in_port_t port = 33367;
|
||||||
|
@ -205,10 +204,10 @@ escapeForLastFM(NSString *string)
|
||||||
|
|
||||||
// Get the first command to be sent
|
// Get the first command to be sent
|
||||||
@synchronized([self queue]) {
|
@synchronized([self queue]) {
|
||||||
enumerator = [[self queue] objectEnumerator];
|
if ([[self queue] count]) {
|
||||||
command = [[enumerator nextObject] retain];
|
command = [[self queue] objectAtIndex:0];
|
||||||
|
[[self queue] removeObjectAtIndex:0];
|
||||||
[[self queue] removeObjectIdenticalTo:command];
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nil != command) {
|
if(nil != command) {
|
||||||
|
|
|
@ -89,9 +89,7 @@ NSURL *resolveAliases(NSURL *url)
|
||||||
NSMutableArray *newSubpathsDirs = [[NSMutableArray alloc] init];
|
NSMutableArray *newSubpathsDirs = [[NSMutableArray alloc] init];
|
||||||
NSMutableArray *newSubpaths = [[NSMutableArray alloc] init];
|
NSMutableArray *newSubpaths = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
NSEnumerator *e = [contents objectEnumerator];
|
for (NSString *s in contents)
|
||||||
NSString *s;
|
|
||||||
while ((s = [e nextObject]))
|
|
||||||
{
|
{
|
||||||
if ([s characterAtIndex:0] == '.')
|
if ([s characterAtIndex:0] == '.')
|
||||||
{
|
{
|
||||||
|
|
|
@ -138,10 +138,9 @@ The footer at the end of APE tagged files (can also optionally be at the front o
|
||||||
-(NSDictionary*) convertToCogTag {
|
-(NSDictionary*) convertToCogTag {
|
||||||
//NSLog(@"Converting ape tag to cog tag");
|
//NSLog(@"Converting ape tag to cog tag");
|
||||||
NSMutableDictionary* d = [NSMutableDictionary dictionaryWithCapacity:6];
|
NSMutableDictionary* d = [NSMutableDictionary dictionaryWithCapacity:6];
|
||||||
NSEnumerator *e = [fields objectEnumerator];
|
|
||||||
ApeTagItem* item;
|
ApeTagItem* item;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
while ((item = [e nextObject]) != nil) {
|
for (item in fields) {
|
||||||
if (![[item tag] compare:APE_TAG_FIELD_ARTIST]) { [d setObject:[item getString] forKey:@"artist"]; n++;}
|
if (![[item tag] compare:APE_TAG_FIELD_ARTIST]) { [d setObject:[item getString] forKey:@"artist"]; n++;}
|
||||||
if (![[item tag] compare:APE_TAG_FIELD_ALBUM]) {[d setObject:[item getString] forKey:@"album"]; n++;}
|
if (![[item tag] compare:APE_TAG_FIELD_ALBUM]) {[d setObject:[item getString] forKey:@"album"]; n++;}
|
||||||
if (![[item tag] compare:APE_TAG_FIELD_TITLE]) {[d setObject:[item getString] forKey:@"title"]; n++;}
|
if (![[item tag] compare:APE_TAG_FIELD_TITLE]) {[d setObject:[item getString] forKey:@"title"]; n++;}
|
||||||
|
@ -158,9 +157,8 @@ The footer at the end of APE tagged files (can also optionally be at the front o
|
||||||
-(NSData*) pack {
|
-(NSData*) pack {
|
||||||
int len = 0, num = 0;
|
int len = 0, num = 0;
|
||||||
NSMutableData* d = [NSMutableData dataWithCapacity:8];
|
NSMutableData* d = [NSMutableData dataWithCapacity:8];
|
||||||
NSEnumerator *e = [fields objectEnumerator];
|
|
||||||
id item;
|
id item;
|
||||||
while ((item = [e nextObject]) != nil)
|
for (item in fields)
|
||||||
{
|
{
|
||||||
NSData* i = [item pack];
|
NSData* i = [item pack];
|
||||||
[d appendData:i];
|
[d appendData:i];
|
||||||
|
|
|
@ -98,10 +98,8 @@
|
||||||
|
|
||||||
NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];
|
NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];
|
||||||
|
|
||||||
NSString *line;
|
|
||||||
NSScanner *scanner = nil;
|
NSScanner *scanner = nil;
|
||||||
NSEnumerator *e = [[contents componentsSeparatedByString:@"\n"] objectEnumerator];
|
for (NSString *line in [contents componentsSeparatedByString:@"\n"])
|
||||||
while (line = [e nextObject])
|
|
||||||
{
|
{
|
||||||
[scanner release];
|
[scanner release];
|
||||||
scanner = [[NSScanner alloc] initWithString:line];
|
scanner = [[NSScanner alloc] initWithString:line];
|
||||||
|
@ -277,9 +275,7 @@
|
||||||
|
|
||||||
- (CueSheetTrack *)track:(NSString *)fragment
|
- (CueSheetTrack *)track:(NSString *)fragment
|
||||||
{
|
{
|
||||||
CueSheetTrack *t;
|
for (CueSheetTrack *t in tracks) {
|
||||||
NSEnumerator *e = [tracks objectEnumerator];
|
|
||||||
while (t = [e nextObject]) {
|
|
||||||
if ([[t track] isEqualToString:fragment]) {
|
if ([[t track] isEqualToString:fragment]) {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,7 @@
|
||||||
|
|
||||||
CueSheet *cuesheet = [CueSheet cueSheetWithFile:[url path]];
|
CueSheet *cuesheet = [CueSheet cueSheetWithFile:[url path]];
|
||||||
|
|
||||||
NSEnumerator *e = [[cuesheet tracks] objectEnumerator];
|
for (CueSheetTrack *track in [cuesheet tracks]) {
|
||||||
CueSheetTrack *track;
|
|
||||||
while (track = [e nextObject]) {
|
|
||||||
[tracks addObject:[NSURL URLWithString:[[url absoluteString] stringByAppendingFormat:@"#%@", [track track]]]];
|
[tracks addObject:[NSURL URLWithString:[[url absoluteString] stringByAppendingFormat:@"#%@", [track track]]]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,7 @@
|
||||||
CueSheet *cuesheet = [CueSheet cueSheetWithFile:[url path]];
|
CueSheet *cuesheet = [CueSheet cueSheetWithFile:[url path]];
|
||||||
|
|
||||||
NSArray *tracks = [cuesheet tracks];
|
NSArray *tracks = [cuesheet tracks];
|
||||||
CueSheetTrack *track;
|
for (CueSheetTrack *track in tracks)
|
||||||
NSEnumerator *e = [tracks objectEnumerator];
|
|
||||||
while (track = [e nextObject])
|
|
||||||
{
|
{
|
||||||
if ([[url fragment] isEqualToString:[track track]])
|
if ([[url fragment] isEqualToString:[track track]])
|
||||||
{
|
{
|
||||||
|
|
|
@ -93,12 +93,12 @@
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *entry;
|
|
||||||
NSEnumerator *e = [[contents componentsSeparatedByString:@"\n"] objectEnumerator];
|
|
||||||
NSMutableArray *entries = [NSMutableArray array];
|
NSMutableArray *entries = [NSMutableArray array];
|
||||||
|
|
||||||
while ((entry = [[e nextObject] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]))
|
for (NSString *entry in [contents componentsSeparatedByString:@"\n"])
|
||||||
{
|
{
|
||||||
|
entry = [entry stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||||
|
|
||||||
if ([entry hasPrefix:@"#"] || [entry isEqualToString:@""]) //Ignore extra info
|
if ([entry hasPrefix:@"#"] || [entry isEqualToString:@""]) //Ignore extra info
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -99,8 +99,10 @@
|
||||||
NSEnumerator *e = [[contents componentsSeparatedByString:@"\n"] objectEnumerator];
|
NSEnumerator *e = [[contents componentsSeparatedByString:@"\n"] objectEnumerator];
|
||||||
NSMutableArray *entries = [NSMutableArray array];
|
NSMutableArray *entries = [NSMutableArray array];
|
||||||
|
|
||||||
while ((entry = [[e nextObject] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]))
|
for (NSString *entry in [contents componentsSeparatedByString:@"\n"])
|
||||||
{
|
{
|
||||||
|
entry = [entry stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||||
|
|
||||||
NSScanner *scanner = [[NSScanner alloc] initWithString:entry];
|
NSScanner *scanner = [[NSScanner alloc] initWithString:entry];
|
||||||
NSString *lhs = nil;
|
NSString *lhs = nil;
|
||||||
NSString *rhs = nil;
|
NSString *rhs = nil;
|
||||||
|
|
|
@ -97,10 +97,7 @@
|
||||||
NSArray *fileNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];
|
NSArray *fileNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];
|
||||||
NSArray *imageFileNames = [fileNames pathsMatchingExtensions:[NSImage imageFileTypes]];
|
NSArray *imageFileNames = [fileNames pathsMatchingExtensions:[NSImage imageFileTypes]];
|
||||||
|
|
||||||
NSEnumerator *imageEnumerator = [imageFileNames objectEnumerator];
|
for (NSString *fileName in imageFileNames) {
|
||||||
NSString *fileName;
|
|
||||||
|
|
||||||
while (fileName = [imageEnumerator nextObject]) {
|
|
||||||
if ([TagLibMetadataReader isCoverFile:fileName]) {
|
if ([TagLibMetadataReader isCoverFile:fileName]) {
|
||||||
image = [NSData dataWithContentsOfFile:[path stringByAppendingPathComponent:fileName]];
|
image = [NSData dataWithContentsOfFile:[path stringByAppendingPathComponent:fileName]];
|
||||||
break;
|
break;
|
||||||
|
@ -118,10 +115,7 @@
|
||||||
|
|
||||||
+ (BOOL)isCoverFile:(NSString *)fileName
|
+ (BOOL)isCoverFile:(NSString *)fileName
|
||||||
{
|
{
|
||||||
NSEnumerator *coverEnumerator = [[TagLibMetadataReader coverNames] objectEnumerator];
|
for (NSString *coverFileName in [TagLibMetadataReader coverNames]) {
|
||||||
NSString *coverFileName;
|
|
||||||
|
|
||||||
while (coverFileName = [coverEnumerator nextObject]) {
|
|
||||||
if ([[[[fileName lastPathComponent] stringByDeletingPathExtension] lowercaseString] hasSuffix:coverFileName]) {
|
if ([[[[fileName lastPathComponent] stringByDeletingPathExtension] lowercaseString] hasSuffix:coverFileName]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,9 +348,7 @@ static AppleRemote* sharedInstance=nil;
|
||||||
|
|
||||||
- (NSString*) validCookieSubstring: (NSString*) cookieString {
|
- (NSString*) validCookieSubstring: (NSString*) cookieString {
|
||||||
if (cookieString == nil || [cookieString length] == 0) return nil;
|
if (cookieString == nil || [cookieString length] == 0) return nil;
|
||||||
NSEnumerator* keyEnum = [[self cookieToButtonMapping] keyEnumerator];
|
for (NSString *key in [[self cookieToButtonMapping] allKeys]) {
|
||||||
NSString* key;
|
|
||||||
while(key = [keyEnum nextObject]) {
|
|
||||||
NSRange range = [cookieString rangeOfString:key];
|
NSRange range = [cookieString rangeOfString:key];
|
||||||
if (range.location == 0) return key;
|
if (range.location == 0) return key;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue