int ( ^oneFrom)(int) = ^(int anInt) {
return anInt - 1;
};
NSLog(@"1 from 10 is %i", oneFrom(10));
float (^distanceTraveled) (float, float, float) = ^(float startingSpeed, float acceleration, float time )
{
float distance = (startingSpeed * time) + (0.5 * acceleration * time * time );
return distance;
};
float howFar = distanceTraveled( 0.0, 9.8, 1.0);
NSLog(@"howFar : %f", howFar);
Tag // iphone






댓글을 달아 주세요