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

投稿

11月, 2013の投稿を表示しています

%hhd

%hd is used for  short integer  or  unsigned short integer %hhd is for  short short integer  or  unsigned short short integer %ld is for  long integer  or  unsigned long integer %lld is for  long long integer  or  unsigned long long integer Simple as that. Here  h  ,  hh  ,  l  ,  ll  are just length modifiers in %d

object-oriented design

In  Part 1 of this tutorial , you learned the basics of object-oriented design: objects, inheritance, and the model-view-controller pattern. You created the beginnings of a simple application called  Vehicles  to help you gain a better understanding of these concepts.

initWithStyle initWithCoder init

Everything traces back to  init . A  UITableViewCell  is a subclass of  NSObject , so it has an  init method. initWithFrame  is deprecated, and has been for some time (since iOS 3). You shouldn't be using it. It was replaced in iOS 3 with  initWithStyle , which you use to indicate what style of cell you'd like to create. initWithCoder  is another  NSObject  method, part of the  NSCoding  protocol. Again, you can see it in UITableViewCell  because it is a sub-class of  NSObject .  initWithCoder  is used to unarchive an object (perhaps you have saved an object directly to a file, for example).

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 add...