Home > Tags > Objective-c
Objective-c
NSTimeZone タイムゾーン
- 2010-07-29 (木)
- Object-C | iPhone | iPhone SDK 3 | iPhone SDK4
NSTimeZoneのクラスメソッド
- timeZoneWithName:・・・タイムゾーン名でタイムゾーンを作って返します
- timeZoneWithAbbreviation:・・・省略形からタイムゾーンを作って返します
- timeZoneForSecondsFromGMT:・・・グリニッジ標準時からの秒差でタイムゾーンを作って返します
次のソースで、timeZoneWithNameの、タイムゾーン名を取得できます。
#import <CoreFoundation/CoreFoundation.h> NSString *timeZoneinfo = (NSString *)CFTimeZoneCopyKnownNames(); NSLog(@"timeZoneinfo is %@", timeZoneinfo);
例えば、
- ニューヨーク・・・“America/New_York”
- 上海・・・“Asia/Shanghai”
- 東京・・・“Asia/Tokyo”
- ロンドン・・・“Europe/London”
- Comments: 0
- Trackbacks: 0
box2d iPhoneアプリ
ActionScriptでは、有名な物理演算ライブラリ「Box2D」のiPhone版をダウンロードした際の履歴です。
環境は、Mac OSX10.6.3 / XCode 3.2.3 iPhone OS4 で試しました。
■SCM Repositories – box2d
http://box2d.svn.sourceforge.net/viewvc/box2d
http://box2d.svn.sourceforge.net/viewvc/box2d/tags/Box2D-2.0.2/
「Download GNU tarball」からダウンロードします。
「trunk」「tag」「branch」から、tagのサンプルでないと、そのままビルドすると、ビルドエラーが起きます。
SDK4にしたので、「ターゲット」の「iPhone OS Deployment Target」を、iPhone4にします。
Objective-Cでも、Flashのような物理演算ができるのは面白いですね。

色々なサンプルが試せます。
- Comments: 0
- Trackbacks: 0
iPhoneアプリ UITableViewを試す。
- 2010-03-14 (日)
- Object-C | iPhone | iPhone SDK 3
「Macを買うなら…」でおなじみの、秋葉館オンラインショップ
もちろん話題のiPodも本体を含め関連商品充実! ![]()

色々と大変そうなので、避けていたのですが、
UITableViewの基礎を試してみました。
こちらをベースに色々カスタマイズしてみようと思います。
- tableView:cellForRowAtIndexPath: メソッド
indexPathが指定する位置のUITableViewCellのインスタンスを返すようにする。 - tableView:numberOfRowsInSection: メソッド
テーブルが保持するセルの数を返すようにする。
iPhone Dev Center: UITableViewDataSource Protocol Referenceより
@implementation RootViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title =@"UITableView 聖域十二宮編";
//Tableに表示する要素
items_ = [[NSArray alloc] initWithObjects:
@"1月 山羊座 - Capricornus", @"2月 水瓶座 - Aquarius",@"3月 魚座 - Pisces",
@"4月 牡羊座 - Aries", @"5月 牡牛座 - Taurus", @"6月 双子座 - Gemini",
@"7月 蟹座 - Cancer", @"8月 獅子座 - Leo", @"9月 乙女座 - Virgo",
@"10月 天秤座 - Libra", @"11月 蠍座 - Scorpio", @"12月 射手座 - Sagittarius",
nil];
}
<pre>//Viewのリリースに、要素の配列をリリース</pre>
- (void)viewDidUnload {
[items_ release];
}
// テーブルが持っているセルの数を返す
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [items_ count];
}
// UiTableViewCellのインスタンスを返す
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
cell.textLabel.text = [items_ objectAtIndex:indexPath.row];
return cell;
}

セルの選択時にアクションを発生させるには、didSelectedRowAtIndexPathメソッドをオーバライドします。
// セルの選択をハンドリングしてアクションを発生させる
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString* message = [items_ objectAtIndex:indexPath.row];
UIAlertView* alert = [[[UIAlertView alloc] init] autorelease];
alert.message = message;
[alert addButtonWithTitle:@"OK"];
[alert show];
}
- Comments: 0
- Trackbacks: 0
Home > Tags > Objective-c
