Permalink
Browse files

Added the ability to print an error message when no command line attr…

…ibute is given
  • Loading branch information...
1 parent 0d8ff2c commit 643cc85d9ce7a296b1a026b9d1c0aa1709f22d39 Lukas Kubanek committed Apr 26, 2012
Showing with 13 additions and 6 deletions.
  1. +1 −1 DBScan.xcodeproj/project.pbxproj
  2. +3 −2 Sources/FileSourceLoader.m
  3. +9 −3 Sources/main.m
@@ -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>";
@@ -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"]];
}
View
@@ -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];

0 comments on commit 643cc85

Please sign in to comment.