「iOS入門」enum変数を出力するサンプル
サンプルコード
#import <Foundation/Foundation.h>
int main(int argc, charchar * argv[])
{
@autoreleasepool {
/* enum定義 */
enum day {Sunday = 6, Monday = 2, Tuesday, Wednesday, Thursday, Friday, Saturday};
/* enumのパラメータ */
enum day today, tomorrow;
today = Wednesday;
tomorrow = Thursday;
/* enumの値を出力 */
NSLog(@"today = %u", today);
NSLog(@"tomorrow = %u", tomorrow);
enum {alive, die} state;
state = alive;
NSLog(@"state = %d", state);
}
}