Skip to content

Commit

Permalink
Added the ability to print an error message when no command line attr…
Browse files Browse the repository at this point in the history
…ibute is given
  • Loading branch information
Lukas Kubanek committed Apr 26, 2012
1 parent 0d8ff2c commit 643cc85
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DBScan.xcodeproj/project.pbxproj
Expand Up @@ -86,10 +86,10 @@
80ED19411546ACCA00B630EC /* DistanceFunction.h */,
80ED19421546ACCA00B630EC /* EuclidianDistanceFunction.h */,
80ED19431546ACCA00B630EC /* EuclidianDistanceFunction.m */,
80ED19471546ACCA00B630EC /* SourceLoader.h */,
80ED19441546ACCA00B630EC /* FileSourceLoader.h */,
80ED19451546ACCA00B630EC /* FileSourceLoader.m */,
80ED19461546ACCA00B630EC /* main.m */,
80ED19471546ACCA00B630EC /* SourceLoader.h */,
);
path = Sources;
sourceTree = "<group>";
Expand Down
5 changes: 3 additions & 2 deletions Sources/FileSourceLoader.m
Expand Up @@ -11,8 +11,9 @@
@implementation FileSourceLoader

- (NSArray *)load:(NSString *)url {
NSString *content = [NSString stringWithContentsOfFile:url encoding:NSUTF8StringEncoding error:nil];

NSString *content = [NSString stringWithContentsOfFile:url
encoding:NSUTF8StringEncoding
error:nil];
return [content componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"\r\n"]];
}

Expand Down
12 changes: 9 additions & 3 deletions Sources/main.m
Expand Up @@ -16,9 +16,15 @@

int main(int argc, const char *argv[]) {
@autoreleasepool {
id <SourceLoader> loader = [FileSourceLoader new];

NSArray *pointsEntries = [loader load:[[[NSProcessInfo processInfo] arguments] objectAtIndex:1]];
NSArray *pointsEntries;

if ([[[NSProcessInfo processInfo] arguments] count] > 1) {
id <SourceLoader> loader = [FileSourceLoader new];
pointsEntries = [loader load:[[[NSProcessInfo processInfo] arguments] objectAtIndex:1]];
} else {
NSLog(@"Pass the file path with point entries as an argument to this application.");
exit(0);
}

NSMutableArray *points = [NSMutableArray arrayWithCapacity:pointsEntries.count];

Expand Down

0 comments on commit 643cc85

Please sign in to comment.