Commits

Brandon Walkin  committed b6468c1

BWSelectableToolbar - added some verification to the setSelectedItemIdentifier methods

  • Participants
  • Parent commits ed171fd

Comments (0)

Files changed (1)

File BWSelectableToolbar.m

 
 - (void)setSelectedItemIdentifier:(NSString *)itemIdentifier
 {
-	[self switchToItemAtIndex:[itemIdentifiers indexOfObject:itemIdentifier] animate:YES];
+	BOOL validIdentifier = NO;
+	
+	for (NSString *identifier in itemIdentifiers)
+	{
+		if ([identifier isEqualToString:itemIdentifier])
+			validIdentifier = YES;
+	}
+	
+	if (validIdentifier)
+		[self switchToItemAtIndex:[itemIdentifiers indexOfObject:itemIdentifier] animate:YES];
 }
 
 - (void)setSelectedItemIdentifierWithoutAnimation:(NSString *)itemIdentifier
 {
-	[self switchToItemAtIndex:[itemIdentifiers indexOfObject:itemIdentifier] animate:NO];
+	BOOL validIdentifier = NO;
+	
+	for (NSString *identifier in itemIdentifiers)
+	{
+		if ([identifier isEqualToString:itemIdentifier])
+			validIdentifier = YES;
+	}
+	
+	if (validIdentifier)
+		[self switchToItemAtIndex:[itemIdentifiers indexOfObject:itemIdentifier] animate:NO];
 }
 
 - (void)selectFirstItem