スキップしてメイン コンテンツに移動

typedef block

double(^g)(double, double) = ^(double a, double b){
            double c = a +b ;
            return c;

        };

^(double a, double b) // the caret represents a block literal. This block takes two double parameters. Note we don't have to explicitly specify the return type
{
   double c = a + b;
   return c; //
}v



typedef double(^BinaryOpBlock_t)(double, double);
BinaryOpBlock_t operation_creator(int op)
{
   if (op == 0)
      return ^(double x, double y) { return x + y; }; // addition block
   if (op == 1)
      return ^(double x, double y) { return x * y; }; // multiplication block
// ... etc.
}
int main()
{
   BinaryOpBlock_t sum = operation_creator(0); // option '0' represents addition
   NSLog(@"sum of 5.5 and 1.3 is %f", sum(5.5, 1.3));
   NSLog(@"product of 3.3 and 1.0 is %f", operation_creator(1)(3.3, 1.0)); // cool, we've composed the function invocation and the block invocation!
}


typedef NS_ENUM(NSUInteger, MCSwipeTableViewCellState){
    MCSwipeTableViewCellStateNone = 0,
    MCSwipeTableViewCellState1,
    MCSwipeTableViewCellState2,
    MCSwipeTableViewCellState3,
    MCSwipeTableViewCellState4
};

コメント

このブログの人気の投稿

日本に来た 今三週間

四月六日に日本に来た、今三週間になった。 嬉しくなかった、悲しくなかった。 日本の携帯電話のカメラはとてもいいよ、私は今撮影が好きだ、いつも寮に帰る途中で花とか魚とか写真を撮る。これも生活の趣味だ。 滴は綺麗だ 桜が凋んで落ちる 天気がいいとき、自転車に乗って、食材を買った。 自分で料理をつくる、おいしそうでしょう。 昨日清水寺に行った、天気はとても熱いね。日に焼けすぎたので、腕は今赤い。 側に花があるので、赤い清水寺はもっと美しそうだ。 木の色は艶やかだ。