コードを舐める日々

わからないことがわからないことをしる日々

iPhoneアプリ開発の翻訳をやってみたよ。(ウェブ翻訳でw

iPhoneのアプリ開発に興味があるなー思った矢先に下記のサイトが!

AppsAmuck iPhone Development Tutorials and Examples

情報ソースはいつも楽しみに見ていただいている百式さんのブログから。
iPhone用アプリを毎日作ってソースコードごと公開している『Apps Amuck』 | 100SHIKI


iPhone開発のきっかけを作るためにまず一日目をウェブ翻訳を参考に日本語らしく直してみた。おかしい部分はブクマコメかブログコメントにてよろしくお願いします。
Day 1: Minutes to Midnight

Day 1: Minutes to Midnight
初日: 真夜中への数分

Updating User Interface Controls
ユーザーインタフェースコントロールをアップデートします。

Just like any good programmers we decided to bite this off the same day Apple lifted the NDA even faced with the time constraints. Needless to say the first app will be VERY simple, however it does demonstrate some stuff I stumbled on the first time I started coding against the iPhone SDK.
まさしくどんな良いプログラマのように、私たちはアップルが時間制約にむしろ直面しているNDAを解除した同じ日にこれをかみ切ることを決心しました。言うまでもなく、最初のアプリはとても簡単なものであり、iPhone SDKに対してコード化し始めた時にはじめてつまずきました。

The app is "Minutes to Midnight"  it is simply a countdown of the time left I have to finish this app before tomorrow :).  This idea came from my friend Chris Craft who committed (and completed!) 30 day of Windows Mobile development.
アプリは、「真夜中への数分」で、単に、残された時間のカウントダウンするもので明日までにこのアプリを仕上げる必要があります:) このアイデアは、私の友人クリスクラフトからいただいたものです。(そして完成されます!)Windowsによる30日間のモバイル開発です。

To get started fire up xCode and
まずxCodeを始動させなさい。
    * Click: File->New Project.
    * 以下をクリックします。: File->New Project.

From the "New Project" dialog
「New Project」ダイアログから
    * Select: iPhone OS ->Applications-> View-Based Application
    * 以下を選択します。: iPhone OS ->Applications-> View-Based Application

    * Name It: I named mine "MinutesToMidnight"
    * それに名前を付けてください:「MinutesToMidnight」

This project already has a UIView we that will be the main view of or application. I imagine a count down looking like a plastic alarm clock which of cource counts backwards to zero.  Let make our text have a red LED look and our back ground black.
このプロジェクトにはすでにアプリケーションの主要であるUIViewがあります。 私は、ゼロまでカウントダウンするプラスチックの目覚まし時計に似ていると想像します。 テキストは、赤いLEDイメージにしバックグラウンドは黒くしたものにします。

First lets open our UIView interface and give it a black background
最初にUIViewインタフェースを開き、それに黒い背景を与えます。

    * Double Click "MinutesToMidnightViewController.xib" to launch "Interface Builder"
    * 「Interface Builder」をスタートするために、「MinutesToMidnightViewController.xib」をダブルクリックしてください。
    * Click: Tools -> Reveal In Document Window -> View
    * 以下をクリックします。: Tools -> Reveal In Document Window -> View
    * Click: Tools -> Attributes Inspector
    * 以下をクリックします。: Tools -> Attributes Inspector
    * Select the background attribute and set it to Black
    * 背景属性を選び、それをブラックに設定してください。

Now lets add a UILabel that will be the display for our countdown.
現在、私たちのカウントダウンのためのディスプレイになるUILabelを加えます。

    * Click: Tools -> Library
    * 以下をクリックします。: Tools -> Library
    * Drag a Label onto the Main View
    * メイン画面へLabel(ラベル)をドラッグします。
    * Stretch and size the Label to your liking
    * あなたの好みの大きさにラベルを伸ばして分けてください。
    * I recomend centering the text and setting the color to red for this project
    * テキストを中心においてこのプロジェクトのために赤色をセットすることを推奨します。

We need to reference the label in our code so we can update the label
私たちは、ラベルを更新することができるように、コード中のラベルに参照を付ける必要があります。

    * In the document window "File's Owner"
    * ドキュメントウィンドウ 「File's Owner」 において
    * Click: Tools->Idenity Inspector
    * 以下をクリックします。: Tools->Idenity Inspector
    * In the inspector click the + under "Class Outlets"
    * "Class Outlets"の下にある「+」を探してクリックします。
    * Change myOutlet1 to "countdownLabel"
    * myOutlet1を「countdownLabel」に変えます。
    * Change id to UILabel
    * idをUILabelに変えます。
    * Click enter to make sure they commit
    * クリックする事でコミットすることを確認します。

Now we need to update our class file
今、私たちはクラス・ファイルを更新する必要があります。

    * Still in interface builder make sure "File's Owner" is still selected in the Document Explorer
    *  * まだInterface Builderでは、「File's Owner」がドキュメントエクスプロラーでまだ選択されているのを確認します。
    * Click: File->Write Class Files
    * 以下をクリックします。:File->Write Class Files
    * Save As: "MinutesToMidnightViewController"
    * 「MinutesToMidnightViewController」と名前をつけて保存します。
    * Click: Save
    * 以下をクリックします。:save
    * Click: Merge
    * 以下をクリックします。:Merge
    * In Actions drop down (bottom right) choose "Select Left"
    * ドロップダウンすることで(右下)「Select Left」を選択します。
    * Click: red circle in title to close the window
    * 以下をクリックします。:ウィンドウを閉じるにあるタイトルバー内の赤い円
    * Click: Save
    * 以下をクリックします。:Save
    * Close the last merge window
    * 最後のMerowウィンドウを閉じます。
    * Open xCode and rebuild project
    * xCodeを開き、プロジェクトをリビルドします。

Now we need to wire up the Label in Interface Builder to the UILabel in the class file
今、私たちは、クラス・ファイル中のUILabelへのInterface Builderの中のラベルを結びつける必要があります。

    * Reopen Interface Builder
    * Interface Builderを再開します。
    * Select the Label in the View or in Document Window
    * 表示またはドキュメントウィンドウにおいてラベルを選んでください。
    * Click: Tools -> Connection Inspector
    * 以下をクリックします。:Tools -> Connection Inspector
    * Move your mouse cursor over the empty circle to the right of text "New Referencing Outlet" (the circle will change to a Plus(+))
    * マウスカーソルをテキスト「New Referencing Outlet」の右への空の円の上に動かします。(円は、プラス(+)に変わります)
    * Mouse Click then drag the Plus (+) to "File's Owner" in Document Window
    * クリックし、その後ドキュメントウィンドウの中にある「File's Owner」にプラス(+)をドラッグします。
    * When you release select countdownLabel in the popup list
    * リリースする時は、ポップアップリストのcountdownLabelを選びます。
    * Click: File -> Save then close Interface Builder
    * 以下をクリックします。:File -> Save  そしてInterface Builderを閉じます。

Return to xCode and rebuild the project
xCodeに戻り、プロジェクトをリビルドします。

Okay getting closer,  we need to do the following to finish up.
完成間近になりましたが、我々は終えるために以下をする必要があります。

    * Start a timer
    * タイマを始動します。
    * Update the label on timer
    * タイマー上のラベルを更新します。
    * Select a cool (nastalgic) font
    * クールな(nastalgic)字体を選択します。

Start Timer
タイマーを始動します。

    * In xCode open
    * 開いたxCodeの中で
    * In MinutesToMidnightViewController.h add the line -(void)updateLabel; right before the line @end
    * MinutesToMidnightViewController.hの中に、ライン@endの直前にライン(void)updateLabelを加えます。
    * In MinutesToMidnightViewController.c add the lines
    * MinutesToMidnightViewController.cの中に、ラインを加えます。

        -(void)updateLabel {
        } 
        right before the line @end

    * In MinutesToMidnightAppDelegate.h add the field "NSTimer *timer;" and the method signature "-(void) onTimer;"
    * MinutesToMidnightAppDelegate.hの中に、「NSTimer *timer;」というフィールド、および「-(void)onTimer;」というコードを追加してください。
    * In MinutesToMidnightAppDelegate.m
    * MinutesToMidnightAppDelegate.mの中で

    * Start the timer in "applicationDidFinishLaunching"
    * 「applicationDidFinishLaunching」でタイマを始動します。
    * Add the method onTimer that will update the label in the view controller
    * 表示コントローラでラベルをアップデートするメソッドonTimerを加えます。
    * Invalidat the timer in the method "applicationWillTerminate"
    * Invalidatはメソッド「applicationWillTerminate」のタイマーになります。
    * release the timer in dealloc
    * deallocの中のタイマーをリリースします。

Update the label
ラベルを更新します。

    * Open MinutesToMidnightViewController.c
    * MinutesToMidnightViewController.cを開きます。
    * Add code to set or cool font in method "viewDidLoad"
    *メソッド「viewDidLoad」にフォントをセットするか、クールなフォントを加えます。
    * Add code to get current time and update label in our new "updateLabel" method.
    * 私たちの新しい「(updateLabel)」メソッドの現在の時刻および最新版ラベルを得るためにコードを加えてください。

Now just build and run in the simulator.
さて、シミュレータにすぐ構築して起動します。

次は2日目をやってみようかな。
その前に開発してみろよ、(おry

iPhoneアプリの開発環境を整えるには下記のリンクがうまくまとまっていて、おすすめ。
iPhoneアプリ開発関連情報 - もとまか日記