Cocoa,Objective-Cでのuse(使用)、composition(合成) ― 2011/06/12 08:03
Mac OS X Cocoa プログラミング(原本はCocoa programming for mac os X)の継承(inherits from)ではなくて
usesもしくは"Knows About''を使う方が良いと書いてあるが
uses -> 使用、known About -> 知っている
が理解できない。Obejctive-Cでは composition(合成)で知られていると書かれているのだが
どこかに sample無いかな?
Sample 生まれてから何日生きてきたか? ― 2011/06/12 21:53
生まれてから 何日生きてきたか?
プロト Objective−Cで書いてみた。
NSCalendarDateを使ってみた
-----以下 サンプル
//
// main.m
// NSCalendarDate_sample
//
// Created by 鈴木 重則 on 11/06/12.
// Copyright 2011 none. All rights reserved.
//
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
int count,count1,count2;
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// my brith day
NSCalendarDate *theDate1 = [NSCalendarDate
dateWithString:@"Sunday, 13 June 1957, 00:32 AM"
calendarFormat:@"%A, %d %B %Y, %I:%M %p"];
NSLog([NSString stringWithFormat:@" %d",[theDate1 dayOfCommonEra]]);
count1 = [theDate1 dayOfCommonEra];
// target day
NSCalendarDate *theDate2 = [NSCalendarDate
dateWithString:@"Sunday, 12 June 2011, 00:32 AM"
calendarFormat:@"%A, %d %B %Y, %I:%M %p"];
NSLog([NSString stringWithFormat:@" %d",[theDate2 dayOfCommonEra]]);
count2 = [theDate2 dayOfCommonEra];
count = count2 - count1;
NSLog(@" count day = %d, Year = %d",count,count/365);
// NSLog([NSString stringWithFormat:@" %d",[theDate dayOfYear]]);
// insert code here...
// NSLog(@"Hello, World!");
[pool drain];
return 0;
}
プロト Objective−Cで書いてみた。
NSCalendarDateを使ってみた
-----以下 サンプル
//
// main.m
// NSCalendarDate_sample
//
// Created by 鈴木 重則 on 11/06/12.
// Copyright 2011 none. All rights reserved.
//
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
int count,count1,count2;
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// my brith day
NSCalendarDate *theDate1 = [NSCalendarDate
dateWithString:@"Sunday, 13 June 1957, 00:32 AM"
calendarFormat:@"%A, %d %B %Y, %I:%M %p"];
NSLog([NSString stringWithFormat:@" %d",[theDate1 dayOfCommonEra]]);
count1 = [theDate1 dayOfCommonEra];
// target day
NSCalendarDate *theDate2 = [NSCalendarDate
dateWithString:@"Sunday, 12 June 2011, 00:32 AM"
calendarFormat:@"%A, %d %B %Y, %I:%M %p"];
NSLog([NSString stringWithFormat:@" %d",[theDate2 dayOfCommonEra]]);
count2 = [theDate2 dayOfCommonEra];
count = count2 - count1;
NSLog(@" count day = %d, Year = %d",count,count/365);
// NSLog([NSString stringWithFormat:@" %d",[theDate dayOfYear]]);
// insert code here...
// NSLog(@"Hello, World!");
[pool drain];
return 0;
}
Sample 2 生まれてから何日生きてきたか? ― 2011/06/12 22:08
本日のみに変更
---- 以下 サンプル
//
// main.m
// nowDay_sample
//
// Created by 鈴木 重則 on 11/06/12.
// Copyright 2011 none. All rights reserved.
//
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int count,count1,count2;
// NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// my brith day
NSCalendarDate *theDate1 = [NSCalendarDate
dateWithString:@"Sunday, 13 June 1957, 00:32 AM"
calendarFormat:@"%A, %d %B %Y, %I:%M %p"];
NSLog([NSString stringWithFormat:@" %d",[theDate1 dayOfCommonEra]]);
count1 = [theDate1 dayOfCommonEra];
// now time
NSDate *theDate2;
theDate2 = [NSCalendarDate calendarDate];
count2 = theDate2;
NSLog([theDate2 description]);
count2 = [theDate2 dayOfCommonEra];
count = count2 - count1;
NSLog(@" count day = %d, Year = %d",count,count/365);
// insert code here...
//NSLog(@"Hello, World!");
[pool drain];
return 0;
}
---- 以下 サンプル
//
// main.m
// nowDay_sample
//
// Created by 鈴木 重則 on 11/06/12.
// Copyright 2011 none. All rights reserved.
//
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int count,count1,count2;
// NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// my brith day
NSCalendarDate *theDate1 = [NSCalendarDate
dateWithString:@"Sunday, 13 June 1957, 00:32 AM"
calendarFormat:@"%A, %d %B %Y, %I:%M %p"];
NSLog([NSString stringWithFormat:@" %d",[theDate1 dayOfCommonEra]]);
count1 = [theDate1 dayOfCommonEra];
// now time
NSDate *theDate2;
theDate2 = [NSCalendarDate calendarDate];
count2 = theDate2;
NSLog([theDate2 description]);
count2 = [theDate2 dayOfCommonEra];
count = count2 - count1;
NSLog(@" count day = %d, Year = %d",count,count/365);
// insert code here...
//NSLog(@"Hello, World!");
[pool drain];
return 0;
}
節電は? ― 2011/06/13 09:48
3月からの電気使用量
4月 228kWh 期間:3/11-4/12
5月 217kWh 期間:4/16-5/15
6月 178kWh 期間:5/16-6/12
やっと 200kWhを切った。
4月 228kWh 期間:3/11-4/12
5月 217kWh 期間:4/16-5/15
6月 178kWh 期間:5/16-6/12
やっと 200kWhを切った。
Lionでgcc-4.5.3 makeは まだ NG ― 2011/06/18 20:23
mac os X (Lion)の環境でgcc-4.5.3をmakeしてみた
HomeBrewだと gmp,mfprは使えるがmpcが古いの
最新0.9を入れて configureでまずは Cを作成しようとしたところ
makeして作成中に
libgccで落ちる
config.logでは conftest.c:1:0: internal compiler error: Segmentation fault: 11
Snow Leoparde環境でmakeしてみる。
HomeBrewだと gmp,mfprは使えるがmpcが古いの
最新0.9を入れて configureでまずは Cを作成しようとしたところ
makeして作成中に
libgccで落ちる
config.logでは conftest.c:1:0: internal compiler error: Segmentation fault: 11
Snow Leoparde環境でmakeしてみる。
最近のコメント