Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

handling edge case

  • Loading branch information...
commit ba6172e97d76cd7dbe55cb43ecbba042db23c164 1 parent e2ba84e
@setuid setuid authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 libmusic/libmusic/libmusic/Chord.m
View
12 libmusic/libmusic/libmusic/Chord.m
@@ -93,9 +93,12 @@ - (id) initWithCifra:(NSString *)c {
+ (BOOL) isValidChord:(NSString *) cifra {
NSError* error = nil;
- NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:CIFRA_REGEX
- options:NSRegularExpressionCaseInsensitive
- error:&error];
+ NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern: CIFRA_REGEX
+ options: NSRegularExpressionCaseInsensitive
+ error: &error];
+
+ if( error )
+ return NO;
NSArray* matches = [regex matchesInString:cifra options:0 range:NSMakeRange(0, [cifra length]) ];
return ( [matches count] > 0 );
@@ -136,6 +139,7 @@ - (void) buildChord {
[self matchNineths];
}
+#pragma mark - Regex Matches for Cifra Components
-( void ) matchRootNote
{
NSError* error = nil;
@@ -388,6 +392,8 @@ -( void ) matchNineth
}
+
+#pragma mark - Utils Methods
- (NSInteger) signature {
return [rootNote noteIndex] + [secondNote noteIndex] + [thirdNote noteIndex] + [fourthNote noteIndex];
}
Please sign in to comment.
Something went wrong with that request. Please try again.