Skip to content

Instantly share code, notes, and snippets.

@yllan
Created June 26, 2011 18:51
Show Gist options
  • Select an option

  • Save yllan/1047853 to your computer and use it in GitHub Desktop.

Select an option

Save yllan/1047853 to your computer and use it in GitHub Desktop.
Step support two directions
void (^((^step)(CGFloat, CGFloat, CGFloat)))(void (^)(CGFloat)) = ^(CGFloat begin, CGFloat end, CGFloat delta) {
if (begin <= end) {
return (void (^)(void (^)(CGFloat)))[[^(void (^block)(CGFloat)) {
for (CGFloat v = begin; v < end; v += delta) {
block(v);
}
} copy] autorelease];
} else {
return (void (^)(void (^)(CGFloat)))[[^(void (^block)(CGFloat)) {
for (CGFloat v = begin; v >= end; v -= delta) {
block(v);
}
} copy] autorelease];
}
};
step(fromProgress, toProgress, 0.025)(^(CGFloat progress) {
// something must be wrong
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment