I use AppCode to tweak the code I've written in XCode. AppCode does awesome code inspections, and tells you where things can be improved.
One of the frequent inspections I come across points out that [SomeObjCFrameworkClass objectAtIndex]
is expecting an NSUInteger
which is in fact true...
- (ObjectType)objectAtIndex:(NSUInteger)index
however, I keep finding myself getting screwed by trying to follow this advice and change my int
s to NSUInteger
s.
For example, here's one piece of code that exploded when I did this change...
-(void)removeBadge
{
if ([[theButton subviews] count]>0)
{
NSUInteger initalValue = [[theButton subviews] count]-1;
//Get reference to the subview, and if it's a badge, remove it from it's parent (the button)
for (NSUInteger i=initalValue; i>=0; i--) {
if ([[[theButton subviews] objectAtIndex:i] isMemberOfClass:[MKNumberBadgeView class]])
{
[[[theButton subviews] objectAtIndex:i] removeFromSuperview];
[theButton setTitleColor:[UIColor lightTextColor] forState:UIControlStateNormal];
}
}
}
}
Any idea why this is happening. There is a clue in the debug data pictured below, but I can't make sense of it.