SkillAgentSearch skills...

BFDirectoryEnumerator

Enumerate directories in breadth first fashion. iOS and OSX

Install / Use

/learn @nofelmahmood/BFDirectoryEnumerator
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

BFDirectoryEnumerator

Enumerate directories in breadth first fashion. iOS and OSX.

Download and run the sample project to see the urls of your Home Directory printed in Breadth first manner in Xcode's log.

Why ?

NSDirectoryEnumerator enumerates directories in depth first manner. In a recent project of an OSX App I wanted it to iterate in breadth first manner. So allow me to introduce

BFDirectoryEnumerator

Its a NSOperation Subclass. You can add it to a NSOperationQueue or just call start on an instance of its object.

Add It

Add these two files to your project.

BFDirectoryEnumerator.h
BFDirectoryEnumerator.m

Import It

#import "BFDirectoryEnumerator.h"

Declare it

@property(strong,nonatomic)BFDirectoryEnumerator *bFDirectoryEnumerator;

Set it

[self setBFDirectoryEnumerator:[BFDirectoryEnumerator enumeratorWithDirectoryURL:[NSURL URLWithString:NSHomeDirectory()] withOptions:NSDirectoryEnumerationSkipsHiddenFiles]];
[[self bFDirectoryEnumerator]setDelegate:self];

Implement BFDirectoryEnumeratorDelegate Protocol and its these two required methods

-(void)bFDirectoryEnumerator:(BFDirectoryEnumerator *)enumerator didScanFileWithURL:(NSURL *)url
{
    NSLog(@"%@",url);
}
-(void)bfDirectoryEnumerator:(BFDirectoryEnumerator *)enumerator didFailWithError:(NSError *)error
{
    
}

Go !

[[self bFDirectoryEnumerator]start];
View on GitHub
GitHub Stars11
CategoryDevelopment
Updated4y ago
Forks2

Languages

Objective-C

Security Score

60/100

Audited on Oct 25, 2021

No findings