'Objective-C'에 해당되는 글 6건

  1. block coding 2011/06/23

block coding

from Objective-C 2011/06/23 11:38

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);



URL : http://developer.apple.com/library/ios/ ··· -ch5-sw4


2011/06/23 11:38 2011/06/23 11:38
Tag //

댓글을 달아 주세요