Permalink
Browse files

More explicit ZAttributeRun* access.

Instead of indirectly accessing the `attributes` property through
NSArray accessors (which return `id`), help out stricter compilers by
explicitly using the `ZAttributeRun` type.  This also makes the code
slighly easier to read.
  • Loading branch information...
1 parent e68e3fe commit fbb1d949408695cea120d99ffcb5b9ecf0aa89e0 Jon Parise committed Oct 5, 2011
Showing with 6 additions and 5 deletions.
  1. +6 −5 FontLabel/Classes/FontLabel/ZAttributedString.m
@@ -455,11 +455,12 @@ - (NSRange)rangeOfAttributeRunsForRange:(NSRange)range {
}
lastRun = run;
}
-
- if (((ZAttributeRun *)[_attributes lastObject]).index < NSMaxRange(range)) {
+
+ lastRun = [_attributes lastObject];
+ if (lastRun.index < NSMaxRange(range)) {
NSRange subrange = NSMakeRange(first, [_attributes count] - first);
if (NSMaxRange(range) < [_buffer length]) {
- ZAttributeRun *newRun = [[ZAttributeRun alloc] initWithIndex:NSMaxRange(range) attributes:[[_attributes lastObject] attributes]];
+ ZAttributeRun *newRun = [[ZAttributeRun alloc] initWithIndex:NSMaxRange(range) attributes:lastRun.attributes];
[_attributes addObject:newRun];
[newRun release];
}
@@ -482,8 +483,8 @@ - (NSRange)rangeOfAttributeRunsForRange:(NSRange)range {
}
if ([[_attributes objectAtIndex:firstAfter] index] > NSMaxRange(range)) {
// the first after is too far after, insert another run!
- ZAttributeRun *newRun = [[ZAttributeRun alloc] initWithIndex:NSMaxRange(range)
- attributes:[[_attributes objectAtIndex:firstAfter-1] attributes]];
+ ZAttributeRun *nextRun = [_attributes objectAtIndex:firstAfter-1];
+ ZAttributeRun *newRun = [[ZAttributeRun alloc] initWithIndex:NSMaxRange(range) attributes:nextRun.attributes];
[_attributes insertObject:newRun atIndex:firstAfter];
[newRun release];
}

0 comments on commit fbb1d94

Please sign in to comment.