<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cocoa*life &#187; Cocoa</title>
	<atom:link href="http://www.cocoalife.net/category/programming/cocoa/feed" rel="self" type="application/rss+xml" />
	<link>http://www.cocoalife.net</link>
	<description>Whether we can achieve something entirely depends upon our intensity of faith.</description>
	<lastBuildDate>Sun, 22 May 2011 10:42:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to use Xcode 3 color themes in Xcode 4</title>
		<link>http://www.cocoalife.net/2011/03/post_872.html</link>
		<comments>http://www.cocoalife.net/2011/03/post_872.html#comments</comments>
		<pubDate>Wed, 30 Mar 2011 11:55:55 +0000</pubDate>
		<dc:creator>milkcocoa</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://www.cocoalife.net/?p=872</guid>
		<description><![CDATA[I&#8217;m using either MyBlackboard (In Japanese) or Railscasts color themes in Xcode 3, these color themes, however, couldn&#8217;t be used in Xcode 4. I want to convert 3&#8242;s xccolortheme files into 4&#8242;s dvtcolortheme files, and found the just script which converted it. mrevilme&#8217;s gist: 488120 — Gist The usage of this tiny python script is [...]]]></description>
			<content:encoded><![CDATA[				<p>I&#8217;m using either <a target="_blank" href="http://d.hatena.ne.jp/griffin-stewie/20090519/p1">MyBlackboard (In Japanese)</a> or <a target="_blank" href="http://blog.codefront.net/2010/02/04/railscasts-xcode-theme/">Railscasts</a> color themes in Xcode 3, these color themes, however, couldn&#8217;t be used in Xcode 4.</p>
				<p>I want to convert 3&#8242;s xccolortheme files into 4&#8242;s dvtcolortheme files, and found the just script which converted it.<br />
				<a target="_blank" href="https://gist.github.com/488120">mrevilme&#8217;s gist: 488120 — Gist</a></p>
				<p>The usage of this tiny python script is very simple like the following command.</p>
				<pre class="brush: bash; title: ; notranslate">$ xcode3_theme_to_xcode4.py MyBlackBoard.xcolortheme</pre>
<p>This step is very quick, and finally, I moved the dvtcolortheme file to the directory.</p>
<pre class="brush: bash; title: ; notranslate">mkdir -p ~/Library/Developer/Xcode/UserData/FontAndColorThemes/
mv MyBlackBoard.dvtcolortheme ~/Library/Developer/Xcode/UserData/FontAndColorThemes/</pre>
				<p>If you&#8217;ve already started Xcode, restart it and you&#8217;ll find the theme at the preference of Xcode.</p>
				<h2>References</h2>
				<ul>
				<li><a target="_blank" href="http://d.hatena.ne.jp/griffin-stewie/20090519/p1">Xcodeのテーマ（Color Theme） &#8211; griffin-stewieの日記</a></li>
				<li><a target="_blank" href="http://blog.codefront.net/2010/02/04/railscasts-xcode-theme/">Railscasts Xcode theme &#8211; redemption in a blog</a></li>
				<li><a target="_blank" href="https://gist.github.com/488120">mrevilme&#8217;s gist: 488120 — Gist</a></li>
				<li><a target="_blank" href="https://gist.github.com/524860">mrevilme&#8217;s gist: 524860 — Gist</a></li>
				</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.cocoalife.net/2011/03/post_872.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to support OAuth in ASIHTTPRequest</title>
		<link>http://www.cocoalife.net/2011/01/post_865.html</link>
		<comments>http://www.cocoalife.net/2011/01/post_865.html#comments</comments>
		<pubDate>Mon, 24 Jan 2011 06:14:33 +0000</pubDate>
		<dc:creator>milkcocoa</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://www.cocoalife.net/?p=865</guid>
		<description><![CDATA[ASIHTTPRequest is a brilliant library, when you want to handle HTTP requests. At this time, however, this library doesn&#8217;t support OAuth. You can support it easily with OAuthCore library which is developed by atebits who is the developer of Tweetie a.k.a. Twitter for Mac/iPhone. atebits / OAuthCore / overview – Bitbucket A sample code is [...]]]></description>
			<content:encoded><![CDATA[				<p>ASIHTTPRequest is a brilliant library, when you want to handle HTTP requests.<br />
				At this time, however, this library doesn&#8217;t support OAuth.</p>
				<p>You can support it easily with OAuthCore library which is developed by atebits who is the developer of Tweetie a.k.a. Twitter for Mac/iPhone.<br />
				<a target="_blank" href="https://bitbucket.org/atebits/oauthcore">atebits / OAuthCore / overview – Bitbucket</a></p>
				<p>A sample code is following.</p>
				<pre class="brush: objc; title: ; notranslate">#import &quot;OAuthCore.h&quot;

NSString * const CONSUMER_KEY = @&quot;YOUR_CONSUMER_KEY&quot;;
NSString * const CONSUMER_SECRET = @&quot;YOUR_CONSUMER_SECRET&quot;;
NSString * const ACCESS_TOKEN = @&quot;YOUR_ACCESS_TOKEN&quot;;
NSString * const ACCESS_TOKEN_SECRET = @&quot;YOUR_ACCESS_TOKEN_SECRET&quot;;

NSURL *URL = [NSURL URLWithString:@&quot;http://example.com/api&quot;];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:URL];

[request setPostValue:@&quot;test&quot; forKey:@&quot;test_value&quot;];
[request buildPostBody];

NSString *header = OAuthorizationHeader([request url],
                                        [request requestMethod],
                                        [request postBody],
                                        CONSUMER_KEY,
                                        CONSUMER_SECRET,
                                        ACCESS_TOKEN,
                                        ACCESS_TOKEN_SECRET);

[request addRequestHeader:@&quot;Authorization&quot; value:header];</pre>
				<p>If you want to get &#8220;Access Token&#8221; and &#8220;Access Toke Secret&#8221;, such as you authorize with xAuth, you should set both ACCESS_TOKEN and ACCESS_TOKEN_SECRET, not nil but @&#8221;".</p>
				<h2>References</h2>
				<ul>
				<li><a target="_blank" href="http://groups.google.com/group/asihttprequest/browse_thread/thread/57e8d27717a44671">Oauth signing &#8211; ASIHTTPRequest | Google グループ</a></li>
				<li><a target="_blank" href="http://d.hatena.ne.jp/sugyan/20100819/1282156751">Objective-C向けOAuthライブラリ&#8221;OAuthCore&#8221;を使ってTwitter APIを叩いてみる &#8211; すぎゃーんメモ</a> (In Japanese)</li>
				</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.cocoalife.net/2011/01/post_865.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Data APIs Objective-C Client LibraryをiOS SDKで使用するための準備</title>
		<link>http://www.cocoalife.net/2010/06/post_547.html</link>
		<comments>http://www.cocoalife.net/2010/06/post_547.html#comments</comments>
		<pubDate>Fri, 18 Jun 2010 07:58:27 +0000</pubDate>
		<dc:creator>milkcocoa</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://www.cocoalife.net/?p=547</guid>
		<description><![CDATA[以下の文章は、Google Data APIs Objective-C Client LibraryをiOS SDKで使用するための準備 &#124; アクトインディ技術部隊報告書と同じものです。 今回はGoogle Data APIs Objective-C Client LibraryをiOS SDKで使用するための準備について書きたいと思います。 Google Data APIs Objective-C Client LibraryはGoogleの様々なサービスをObjective-Cから使うことができるライブラリです。 Google Data APIs Objective-C Client Library あらかじめGData.xcodeprojを、ライブラリを使用したいプロジェクトの「ファイルとグループ」欄に追加しておきましょう。 ライブラリをコンパイルする コンパイルオプションを指定してコンパイルします。 今回はPicasaサービスとそれに付随してOAuthを使用したので、以下のオプションを指定しました。 -DGDATA_INCLUDE_PHOTOS_SERVICE=1 -DGDATA_INCLUDE_OAUTH=1 iPhone Simulator版とiPhone OS版をReleaseでコンパイルします。 lipoでFat Binaryにする cd build lipo -create Release-iphoneos/libGDataTouchStaticLib.a Release-iphonesimulator/libGDataTouchStaticLib.a -output libGDataTouchStaticLib.a コンパイルしたライブラリをXcodeに追加する Xcodeの「ターゲット」でアプリを指定し右クリックし「情報を見る」を選択。 「一般」 &#8211; 「リンク済みライブラリ」の下の「+」をクリック。 「その他を追加&#8230;」をクリックし、さきほどコンパイルしたlibGDataTouchStaticLib.aを選択。 コンパイルするための設定を追加する プロジェクトを右クリックし、「情報を見る」を選択。 [...]]]></description>
			<content:encoded><![CDATA[				<p>以下の文章は、<a href="http://tech.actindi.net/3485836586">Google Data APIs Objective-C Client LibraryをiOS SDKで使用するための準備 | アクトインディ技術部隊報告書</a>と同じものです。</p>
				<p>今回はGoogle Data APIs Objective-C Client LibraryをiOS SDKで使用するための準備について書きたいと思います。</p>
				<p>Google Data APIs Objective-C Client LibraryはGoogleの様々なサービスをObjective-Cから使うことができるライブラリです。<br />
				<a target="_blank" href="http://code.google.com/p/gdata-objectivec-client/">Google Data APIs Objective-C Client Library</a></p>
				<p>あらかじめGData.xcodeprojを、ライブラリを使用したいプロジェクトの「ファイルとグループ」欄に追加しておきましょう。</p>
				<h2>ライブラリをコンパイルする</h2>
				<p>コンパイルオプションを指定してコンパイルします。<br />
				今回はPicasaサービスとそれに付随してOAuthを使用したので、以下のオプションを指定しました。</p>
				<pre>-DGDATA_INCLUDE_PHOTOS_SERVICE=1
-DGDATA_INCLUDE_OAUTH=1</pre>
				<p>iPhone Simulator版とiPhone OS版をReleaseでコンパイルします。</p>
				<h2>lipoでFat Binaryにする</h2>
				<pre>cd build
lipo -create Release-iphoneos/libGDataTouchStaticLib.a Release-iphonesimulator/libGDataTouchStaticLib.a -output libGDataTouchStaticLib.a</pre>
				<h2>コンパイルしたライブラリをXcodeに追加する</h2>
				<ul>
				<li>Xcodeの「ターゲット」でアプリを指定し右クリックし「情報を見る」を選択。</li>
				<li>「一般」 &#8211; 「リンク済みライブラリ」の下の「+」をクリック。</li>
				<li>「その他を追加&#8230;」をクリックし、さきほどコンパイルしたlibGDataTouchStaticLib.aを選択。</li>
				</ul>
				<h2>コンパイルするための設定を追加する</h2>
				<ul>
				<li>プロジェクトを右クリックし、「情報を見る」を選択。</li>
				<li>「ビルド」を選ぶ。</li>
				<li>「ヘッダ検索パス」に/usr/include/libxml2を追加。</li>
				<li>「ユーザヘッダ検索パス」にライブラリのフォルダを追加（このとき「再帰的」にチェックを入れる）。</li>
				<li>「常にユーザパスを検索」にチェックを入れる。</li>
				<li>「他のリンカフラグ」に -all_load -ObjC -lxml2 を指定。</li>
				</ul>
				<h2>参考文献</h2>
				<ul>
				<li><a target="_blank" href="http://code.google.com/p/gdata-objectivec-client/wiki/BuildingTheLibrary#Linking_to_the_iPhone_Static_Library">BuildingTheLibrary &#8211; gdata-objectivec-client &#8211; Adding the Google Data API Objective-C Client Library to a Project &#8211; Project Hosting on Google Code</a></li>
				<li><a href="http://d.hatena.ne.jp/unarrator/20100602">gdata-objectivec-clientを一部手動でstatic library化 &#8211; Undecidable Narrator &#8211; 曖昧な語り手</a></li>
				<li><a href="http://www.awaresoft.jp/development/35-iphone-app/62-building-gdata-api-client-library-for-iphone.html">Google Data API クライアントライブラリのビルド &#8211; Awaresoft</a></li>
				<li><a target="_blank" href="http://blog.boreal-kiss.com/2009/08/29000009.html">[iPhone] cocos2dを静的ライブラリ化して使う : boreal-kiss.com</a></li>
				</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.cocoalife.net/2010/06/post_547.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-Cでメンバ変数に動的にアクセスする方法</title>
		<link>http://www.cocoalife.net/2010/04/post_548.html</link>
		<comments>http://www.cocoalife.net/2010/04/post_548.html#comments</comments>
		<pubDate>Sun, 25 Apr 2010 01:24:58 +0000</pubDate>
		<dc:creator>milkcocoa</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://www.cocoalife.net/?p=548</guid>
		<description><![CDATA[以下の文章はObjective-Cでメンバ変数に動的にアクセスする方法 &#124; アクトインディ技術部隊報告書と同様のものです。 今回、複数回使い回したいViewがあったのですが、一方で様々なところで使われるものではありませんでした。 こんなときにわざわざクラスを作るのはどうも重い感じがしてしまいます。 そこでUIViewのサブクラスを作らずに、メソッドで作ることにしました。 UIViewController 今回作成したいView 今回作成したいView というように複数個必要です。 このViewの中身はUILabelが2つだけ。 さらに出来ることなら、作成するViewの中身であるUILabelを、このViewを持っているViewControllerのメンバ変数からアクセスしたい。 以前はTagを割り当ててアクセスしていたのですが、意外と面倒だったのでそれ以外の方法がないかどうか調べてみました。 実際には以下のようなコードを使用することで出来ました。 titleLabelName, contentLabelNameにはそれぞれに割り当てたいメンバ変数の名称を指定します。 こんな感じにobject_setInstanceVariable関数を使用してあげれば、割り当てたいメンバ変数に割り当てることが出来ます。 P.S. といいつつも、実は様々なところで使われる必要がわかり、まじめにUIViewのサブクラスを作成したため、上記のコードはお蔵入りになりました。 参考文献 【コラム】ダイナミックObjective-C (31) ランタイムAPIでさらに動的に(5) &#8211; インスタンス変数に動的にアクセス &#124; エンタープライズ &#124; マイコミジャーナル]]></description>
			<content:encoded><![CDATA[				<p>以下の文章は<a target="_blank" href="http://tech.actindi.net/3481147128">Objective-Cでメンバ変数に動的にアクセスする方法 | アクトインディ技術部隊報告書</a>と同様のものです。</p>
				<p>今回、複数回使い回したいViewがあったのですが、一方で様々なところで使われるものではありませんでした。<br />
				こんなときにわざわざクラスを作るのはどうも重い感じがしてしまいます。<br />
				そこでUIViewのサブクラスを作らずに、メソッドで作ることにしました。</p>
				<ul>
				<li>UIViewController
				<ul>
				<li>今回作成したいView</li>
				<li>今回作成したいView</li>
				</ul>
				</ul>
				<p>というように複数個必要です。<br />
				このViewの中身はUILabelが2つだけ。</p>
				<p>さらに出来ることなら、作成するViewの中身であるUILabelを、このViewを持っているViewControllerのメンバ変数からアクセスしたい。<br />
				以前はTagを割り当ててアクセスしていたのですが、意外と面倒だったのでそれ以外の方法がないかどうか調べてみました。</p>
				<p>実際には以下のようなコードを使用することで出来ました。</p>
				<pre class="brush: objc; title: ; notranslate">#include &lt;objc/runtime.h&gt;

@implementation HogeViewController

- (UIView *)generateView:(NSString *)titleLabelName contentLabelName:(NSString *)contentLabelName
{
    UIView   *resultView;
    UILabel  *titleLabel, *contentLabel;

    // 便宜上CGRectZeroを使います。
    resultView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];

    titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    [resultView addSubview:titleLabel];
    [titleLabel release];

    object_setInstanceVariable(self, [titleLabelName UTF8String], titleLabel);

    contentLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    [resultView addSubview:contentLabel];
    [contentLabel release];

    object_setInstanceVariable(self, [contentLabelName UTF8String], contentLabel);

    return resultView;
}

@end</pre>
				<p>titleLabelName, contentLabelNameにはそれぞれに割り当てたいメンバ変数の名称を指定します。<br />
				こんな感じにobject_setInstanceVariable関数を使用してあげれば、割り当てたいメンバ変数に割り当てることが出来ます。</p>
				<p>P.S.<br />
				といいつつも、実は様々なところで使われる必要がわかり、まじめにUIViewのサブクラスを作成したため、上記のコードはお蔵入りになりました。</p>
				<h2>参考文献</h2>
				<ul>
				<li><a target="_blank" href="http://journal.mycom.co.jp/column/objc/031/index.html">【コラム】ダイナミックObjective-C (31) ランタイムAPIでさらに動的に(5) &#8211; インスタンス変数に動的にアクセス | エンタープライズ | マイコミジャーナル</a></li>
				</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.cocoalife.net/2010/04/post_548.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UITableViewにcellを動的に追加/削除する2つの方法。</title>
		<link>http://www.cocoalife.net/2010/04/post_543.html</link>
		<comments>http://www.cocoalife.net/2010/04/post_543.html#comments</comments>
		<pubDate>Wed, 14 Apr 2010 03:57:48 +0000</pubDate>
		<dc:creator>milkcocoa</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://www.cocoalife.net/?p=543</guid>
		<description><![CDATA[以下の文章はUITableViewにcellを動的に追加/削除する2つの方法。 &#124; アクトインディ技術部隊報告書と同様のものです。 UITableViewにcellを動的に追加/削除するということについて書こうと思います。 特にこれまでUITableViewのbeginUpdatesとendUpdatesという二つのメソッドを、いったいどんな場合に使用したらいいのか明確になっていませんでした。 ここら辺を重点的に書きたいと思います。 以下のAppleの公式ドキュメントにかなり詳しく書かれています。 Table View Programming Guide for iPhone OS: Inserting and Deleting Rows and Sections cellを一つずつ追加/削除していく場合 cellを一つずつ追加/削除していく場合には、beginUpdates/endUpdatesの出番はありません。 追加/削除したいcellのindexPathを作成してinsert(or delete)RowsAtIndexPaths:withRowAnimation:メソッドを呼ぶだけ。 単純です。 ただし注意点はinsertRowsAtIndexPaths:withRowAnimation:メソッドを呼ぶと、UITableViewDataSourceのtableView:cellForRowAtIndexPath:メソッドが呼ばれるということ。 すなわち、cellの中身をNSArray等で管理している場合にはあらかじめNSArrayの内容を変更しておかなければなりません。 cocoa*life &#8211; UITableViewCellを削除ボタンを使って削除する 複数のcellをいっぺんに追加/削除する場合 ここまではbeginUpdatesやendUpdatesを使用する必要はありません。 では、どういうときに使用するべきなのか？ ポイントはbeginUpdates/endUpdatesに関することが書かれているセクションのタイトルがBatch Insertion and Deletion of Rows and Sectionsであるということ。 batchというのは英語で束という意味なので、「いっぺん」に複数のcellを処理したいときに使うということになります。 つまり、このメソッドを使用するかしないかの選択基準の違いは、一つずつかいっぺんかということになります。 もちろん複数のcellを追加/削除したい場合であっても、一つずつ追加/削除することができます。 beginUpdatesとendUpdatesで追加/削除のメソッド群を挟みます。 endUpdatesを呼び出したあと、tableView:cellForRowAtIndexPath:メソッドが呼ばれ、追加と削除の結果が表示されます。 beginUpdatesとendUpdatesで挟まれた追加/削除の挙動は、公式ドキュメントに以下のように書かれています。 The code calls the deleteRowsAtIndexPaths:withRowAnimation: method after it [...]]]></description>
			<content:encoded><![CDATA[				<p>以下の文章は<a target="_blank" href="http://tech.actindi.net/3480206140">UITableViewにcellを動的に追加/削除する2つの方法。 | アクトインディ技術部隊報告書</a>と同様のものです。</p>
				<p>UITableViewにcellを動的に追加/削除するということについて書こうと思います。</p>
				<p>特にこれまでUITableViewのbeginUpdatesとendUpdatesという二つのメソッドを、いったいどんな場合に使用したらいいのか明確になっていませんでした。<br />
				ここら辺を重点的に書きたいと思います。</p>
				<p>以下のAppleの公式ドキュメントにかなり詳しく書かれています。<br />
				<a target="_blank" href="http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/ManageInsertDeleteRow/ManageInsertDeleteRow.html">Table View Programming Guide for iPhone OS: Inserting and Deleting Rows and Sections</a></p>
				<h2>cellを一つずつ追加/削除していく場合</h2>
				<p>cellを一つずつ追加/削除していく場合には、beginUpdates/endUpdatesの出番はありません。<br />
				追加/削除したいcellのindexPathを作成してinsert(or delete)RowsAtIndexPaths:withRowAnimation:メソッドを呼ぶだけ。<br />
				単純です。</p>
				<p>ただし注意点はinsertRowsAtIndexPaths:withRowAnimation:メソッドを呼ぶと、UITableViewDataSourceのtableView:cellForRowAtIndexPath:メソッドが呼ばれるということ。<br />
				すなわち、cellの中身をNSArray等で管理している場合にはあらかじめNSArrayの内容を変更しておかなければなりません。</p>
				<p><a target="_blank" href="http://www.cocoalife.net/2008/12/post_767.html">cocoa*life &#8211; UITableViewCellを削除ボタンを使って削除する</a></p>
				<h2>複数のcellをいっぺんに追加/削除する場合</h2>
				<p>ここまではbeginUpdatesやendUpdatesを使用する必要はありません。<br />
				では、どういうときに使用するべきなのか？</p>
				<p>ポイントはbeginUpdates/endUpdatesに関することが書かれているセクションのタイトルがBatch Insertion and Deletion of Rows and Sectionsであるということ。<br />
				batchというのは英語で束という意味なので、「いっぺん」に複数のcellを処理したいときに使うということになります。</p>
				<p>つまり、このメソッドを使用するかしないかの選択基準の違いは、一つずつかいっぺんかということになります。<br />
				もちろん複数のcellを追加/削除したい場合であっても、一つずつ追加/削除することができます。</p>
				<p>beginUpdatesとendUpdatesで追加/削除のメソッド群を挟みます。<br />
				endUpdatesを呼び出したあと、tableView:cellForRowAtIndexPath:メソッドが呼ばれ、追加と削除の結果が表示されます。</p>
				<p>beginUpdatesとendUpdatesで挟まれた追加/削除の挙動は、公式ドキュメントに以下のように書かれています。</p>
				<dl class="quote">
				<dd>
				<blockquote>
				<p>The code calls the deleteRowsAtIndexPaths:withRowAnimation: method <strong>after</strong> it calls insertRowsAtIndexPaths:withRowAnimation:. However, this is <strong>not the order</strong> in which UITableView completes the operations. It defers <strong>any insertions</strong> of rows or sections <strong>until after</strong> it has handled the deletions of rows or sections. This happens <strong>regardless of ordering of the insertion and deletion</strong> method calls.</p>
				<p>Deletions within an animation block specify which rows and sections in the <strong>original</strong> table should be removed; insertions specify which rows and sections should be added to the <strong>resulting</strong> table.</p>
				</blockquote>
				</dd>
				<dt class="cite"> 引用元: <a target="_blank" href="http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/ManageInsertDeleteRow/ManageInsertDeleteRow.html">Table View Programming Guide for iPhone OS: Inserting and Deleting Rows and Sections</a>（強調は引用者による）</dt>
				</dl>
				<p>この文章をまとめてみました。<br />
				（前提条件としてbeginUpdates/endUpdatesで囲まれている中では）</p>
				<ul>
				<li>deleteRowsAtIndexPaths:withRowAnimation:メソッドをinsertRowsAtIndexPaths:withRowAnimation:メソッドの前に呼ぶことは必須ではない（not the order）。</li>
				<li>実際のcellの追加は削除のあとに行われる。上記メソッドの呼び出し順序は影響を及ぼさない（regardless of ordering of the insertion and deletion）。</li>
				<li>削除時のindexPathにはbeginUpdates呼び出し前、元々の（original）テーブルに対するものを指定し、追加時は削除後の結果となる（resulting）テーブルに対するものを指定する。</li>
				</ul>
				<p>このような仕組みにすることで、以下のページに書かれているように1つのcellを削除するごとにindexPathを調整することが必要なく、削除を直感的に行うことが出来ます。<br />
				<a target="_blank" href="http://iphone-dev.g.hatena.ne.jp/tokorom/20090604/1244083883">テーブルのセルの削除や追加にbeginUpdates/endUpdatesは必要か(2) &#8211; iPhoneアプリ開発まっしぐら★ &#8211; iPhoneアプリ開発グループ</a></p>
				<p>ということで、beginUpdates/endUpdatesメソッドはcellをいっぺんに追加/削除したい場合に使えばよい！ということになります。</p>
				<h2>参考文献</h2>
				<ul>
				<li><a target="_blank" href="http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/ManageInsertDeleteRow/ManageInsertDeleteRow.html">Table View Programming Guide for iPhone OS: Inserting and Deleting Rows and Sections</a></li>
				<li><a target="_blank" href="http://iphone-dev.g.hatena.ne.jp/tokorom/20090603/1244008956">テーブルのセルの削除や追加にbeginUpdates/endUpdatesは必要か(1) &#8211; iPhoneアプリ開発まっしぐら★ &#8211; iPhoneアプリ開発グループ</a></li>
				<li><a target="_blank" href="http://iphone-dev.g.hatena.ne.jp/tokorom/20090604/1244083883">テーブルのセルの削除や追加にbeginUpdates/endUpdatesは必要か(2) &#8211; iPhoneアプリ開発まっしぐら★ &#8211; iPhoneアプリ開発グループ</a></li>
				<li><a target="_blank" href="http://www.cocoalife.net/2008/12/post_767.html">cocoa*life &#8211; UITableViewCellを削除ボタンを使って削除する</a></li>
				</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.cocoalife.net/2010/04/post_543.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Core Animationで遊んでみる (2)</title>
		<link>http://www.cocoalife.net/2010/03/post_545.html</link>
		<comments>http://www.cocoalife.net/2010/03/post_545.html#comments</comments>
		<pubDate>Wed, 24 Mar 2010 03:58:42 +0000</pubDate>
		<dc:creator>milkcocoa</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://www.cocoalife.net/?p=545</guid>
		<description><![CDATA[以下はCore Animationで遊んでみる (2) &#124; アクトインディ技術部隊報告書と同じものです。 以前のエントリに引き続き、Core Animationで少し遊んでみたいと思います。 これも簡単にできるフェード処理です。 以前のエントリと同様、QuartzCore.frameworkをincludeし #import &#60;QuartzCore/QuartzCore.h&#62; とimportすることが必要です。 さて実際にフェード処理を記述してみましょう。 たとえば、hogeViewというViewをフェードアウトしてみます。 フェードインの時はsetHiddenをNoですね。 この方法を用いて、もう一つサンプルを書いてみます。 UINavigationItemのright/leftButtonItemを設定する際にはanimated:YESとすることでフェードイン/アウトしてくれますが、TitleViewはそのような項目はないのでこの方法を使えないかと思いやってみたらできました。 TitleViewにはUISegmentedControlを設定することにします。]]></description>
			<content:encoded><![CDATA[				<p>以下は<a target="_blank" href="http://tech.actindi.net/3478391136">Core Animationで遊んでみる (2) | アクトインディ技術部隊報告書</a>と同じものです。</p>
				<p><a href="http://www.cocoalife.net/2010/03/post_471.html">以前のエントリ</a>に引き続き、Core Animationで少し遊んでみたいと思います。<br />
				これも簡単にできるフェード処理です。</p>
				<p><a href="http://www.cocoalife.net/2010/03/post_471.html">以前のエントリ</a>と同様、QuartzCore.frameworkをincludeし</p>
				<pre>#import &lt;QuartzCore/QuartzCore.h&gt;</pre>
<p>とimportすることが必要です。</p>
<p>さて実際にフェード処理を記述してみましょう。<br />
たとえば、hogeViewというViewをフェードアウトしてみます。</p>
<pre class="brush: objc; title: ; notranslate">CATransition    *transition;
transition = [CATransition animation];

// トランジション時間の設定（これだと1秒）。
[transition setDuration:1.0f];

// トランジションの種類の設定、今回はフェード。
[transition setType:kCATransitionFade];

// トランジション中に起こす処理を記述。
[hogeView setHidden:YES];

// トランジションを実行。
[[[self view] layer] addAnimation:transition forKey:@&quot;layerAnimation&quot;];</pre>
				<p>フェードインの時はsetHiddenをNoですね。</p>
				<p>この方法を用いて、もう一つサンプルを書いてみます。<br />
				UINavigationItemのright/leftButtonItemを設定する際にはanimated:YESとすることでフェードイン/アウトしてくれますが、TitleViewはそのような項目はないのでこの方法を使えないかと思いやってみたらできました。</p>
				<p>TitleViewにはUISegmentedControlを設定することにします。</p>
				<pre class="brush: objc; title: ; notranslate">CATransition    *transition;
transition = [CATransition animation];

[transition setDuration:1.0f];
[transition setType:kCATransitionFade];
[[self navigationItem] setTitleView:segmentedControl];
[[[[self navigationController] navigationBar] layer] addAnimation:transition forKey:@&quot;layerAnimation&quot;];</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cocoalife.net/2010/03/post_545.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Core Animationで遊んでみる (1)</title>
		<link>http://www.cocoalife.net/2010/03/post_471.html</link>
		<comments>http://www.cocoalife.net/2010/03/post_471.html#comments</comments>
		<pubDate>Wed, 24 Mar 2010 03:51:40 +0000</pubDate>
		<dc:creator>milkcocoa</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://www.cocoalife.net/?p=471</guid>
		<description><![CDATA[以下はCore Animationで遊んでみる (1) &#124; アクトインディ技術部隊報告書と同様のものです。 Mac OS X 10.5 Leopardの目玉機能の一つはCore Animationでした。 Appleの触れ込みによると、Core Animationを利用すると簡単にアニメーション処理を追加することができるそうです。 なんですが、アニメーションではないところでも、便利に使うことができます。 今回はiPhone SDKを用いて、そのちょっと便利な使い方を書こうと思います。 以下のサンプルでは全部 QuartzCore.frameworkをincludeし #import &#60;QuartzCore/QuartzCore.h&#62; とimportをすることが必要です。 UIViewを角丸にする UIViewを角丸にするのはとても簡単です。 UIViewに枠線を追加する setBorderColorメッセージの引数はCGColorなので、上記のようにUIColorからCGColorに変更してあげる必要があります。]]></description>
			<content:encoded><![CDATA[				<p>以下は<a target="_blank" href="http://tech.actindi.net/3477781577">Core Animationで遊んでみる (1) | アクトインディ技術部隊報告書</a>と同様のものです。</p>
				<p>Mac OS X 10.5 Leopardの目玉機能の一つはCore Animationでした。<br />
				Appleの触れ込みによると、Core Animationを利用すると簡単にアニメーション処理を追加することができるそうです。</p>
				<p>なんですが、アニメーションではないところでも、便利に使うことができます。<br />
				今回はiPhone SDKを用いて、そのちょっと便利な使い方を書こうと思います。</p>
				<p>以下のサンプルでは全部<br />
				QuartzCore.frameworkをincludeし</p>
				<pre>#import &lt;QuartzCore/QuartzCore.h&gt;</pre>
<p>とimportをすることが必要です。</p>
<h2>UIViewを角丸にする</h2>
<p>UIViewを角丸にするのはとても簡単です。</p>
<pre class="brush: objc; title: ; notranslate">[[view layer] setCornerRadius:10.0];
[view setClipsToBounds:YES];</pre>
				<h2>UIViewに枠線を追加する</h2>
				<pre class="brush: objc; title: ; notranslate">[[view layer] setBorderColor:[[UIColor lightGrayColor] CGColor]];
[[view layer] setBorderWidth:1.0];</pre>
				<p>setBorderColorメッセージの引数はCGColorなので、上記のようにUIColorからCGColorに変更してあげる必要があります。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cocoalife.net/2010/03/post_471.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>UITextFieldに入力されている文字数を動的に、非同期に数える。</title>
		<link>http://www.cocoalife.net/2010/03/post_546.html</link>
		<comments>http://www.cocoalife.net/2010/03/post_546.html#comments</comments>
		<pubDate>Wed, 03 Mar 2010 02:17:12 +0000</pubDate>
		<dc:creator>milkcocoa</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://www.cocoalife.net/?p=546</guid>
		<description><![CDATA[以下はUITextFieldに入力されている文字数を動的に、非同期に数える。 &#124; アクトインディ技術部隊報告書と同じものです。 とあるUITextFieldによる入力フォームと、UIBarButtonItemによる「完了」ボタンがある画面を考えます。 今回のエントリの目的はUITextFieldに文字が入力されていない、つまり空であるときは、「完了」ボタンを表示しない画面を作成するということです。 ポイントはUIControlEventEditingChangedイベントを使うこと。 最初はUITextFieldDelegateのtextField:shouldChangeCharactersInRange:replacementString:とかを使用することを考えましたが、文字を消去したときにボタンが消えない等々うまくいきませんでした。 サンプルコードを書いてみます。 参考 Disable button if textField is empty &#8211; iPhone SDK Development]]></description>
			<content:encoded><![CDATA[				<p>以下は<a target="_blank" href="http://tech.actindi.net/3476570782">UITextFieldに入力されている文字数を動的に、非同期に数える。 | アクトインディ技術部隊報告書</a>と同じものです。</p>
				<p>とあるUITextFieldによる入力フォームと、UIBarButtonItemによる「完了」ボタンがある画面を考えます。</p>
				<p>今回のエントリの目的はUITextFieldに文字が入力されていない、つまり空であるときは、「完了」ボタンを表示しない画面を作成するということです。</p>
				<p>ポイントはUIControlEventEditingChangedイベントを使うこと。<br />
				最初はUITextFieldDelegateのtextField:shouldChangeCharactersInRange:replacementString:とかを使用することを考えましたが、文字を消去したときにボタンが消えない等々うまくいきませんでした。</p>
				<p>サンプルコードを書いてみます。</p>
				<pre class="brush: objc; title: ; notranslate">- (void)setupUserInterface
{
    UIView      *contentView;
    UITextField *textField;

    contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self setView:contentView];
    [contentView release];

    doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
                                                               target:self
                                                               action:@selector(respondsToDoneButtonTouchDown:)];

    textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 100, 20)];
    [contentView addSubview:textField];
    [textField release];
    [textField addTarget:self
                  action:@selector(respondsToEditingChanged:)
        forControlEvents:UIControlEventEditingChanged];
}

- (void)respondsToEditingChanged:(id)sender
{
    if ([sender isKindOfClass:[UITextField class]])
    {
        // 本当はsenderを用いずにメンバ変数とかにしておけばいいのだけれど、今回はあえて型変換をしてみる。
        if ([[(UITextField *)sender text] length])
        {
            [[self navigationItem] setRightBarButtonItem:doneButton animated:YES];
        }
        else
        {
            [[self navigationItem] setRightBarButtonItem:nil animated:YES];
        }
    }
}</pre>
				<p>参考<br />
				<a target="_blank" href="http://groups.google.co.jp/group/iphonesdkdevelopment/browse_thread/thread/0cc9032a397a02ff">Disable button if textField is empty &#8211; iPhone SDK Development</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cocoalife.net/2010/03/post_546.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhoneによる位置情報関係のまとめ</title>
		<link>http://www.cocoalife.net/2010/01/post_498.html</link>
		<comments>http://www.cocoalife.net/2010/01/post_498.html#comments</comments>
		<pubDate>Sun, 31 Jan 2010 14:48:53 +0000</pubDate>
		<dc:creator>milkcocoa</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://www.cocoalife.net/?p=498</guid>
		<description><![CDATA[以下はiPhoneによる位置情報関係のまとめ &#124; アクトインディ技術部隊報告書と同様のものです。 今回も前回のGeohashに引き続き、位置情報に関する内容です。 ググれば出てくる内容なので、新しいことはなんにもないのが申し訳ないところです。 位置情報に関するライブラリは CoreLocation MapKit などがあります。 GPSで現在位置を取得するにはCoreLocationを使用し、地図を表示したり現在地の大まかな住所を取得するためにはMapKitを使用します。 GPSで現在位置を取得するには CoreLocationではCLLocationManagerDelegateを実装し このようにすればLogに現在地の情報が取得できます。 地図を表示するには とすれば、locationで指定した座標に移動します。 現在地を取得するには MKReverseGeocoderDelegateを実装し とすることで取得することができます。 すべてのAPIが非常にシンプルに作られているので、使用するのは非常に簡単です。]]></description>
			<content:encoded><![CDATA[				<p>以下は<a target="_blank" href="http://tech.actindi.net/3473583175">iPhoneによる位置情報関係のまとめ | アクトインディ技術部隊報告書</a>と同様のものです。</p>
				<p>今回も前回のGeohashに引き続き、位置情報に関する内容です。<br />
				ググれば出てくる内容なので、新しいことはなんにもないのが申し訳ないところです。</p>
				<p>位置情報に関するライブラリは</p>
				<ul>
				<li>CoreLocation</li>
				<li>MapKit</li>
				</ul>
				<p>などがあります。</p>
				<p>GPSで現在位置を取得するにはCoreLocationを使用し、地図を表示したり現在地の大まかな住所を取得するためにはMapKitを使用します。</p>
				<h2>GPSで現在位置を取得するには</h2>
				<p>CoreLocationではCLLocationManagerDelegateを実装し</p>
				<pre class="brush: objc; title: ; notranslate">
- (void)setup
{
    CLLocationManager *locationManager = [[CLLocationManager alloc] init];
    if ([locationManager locationServicesEnabled])
    {
        [locationManager setDelegate:self];
        [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
        [locationManager setDistanceFilter:kCLDistanceFilterNone];
    }
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    NSLog(@&quot;%@&quot;, newLocation);
}
</pre>
				<p>このようにすればLogに現在地の情報が取得できます。</p>
				<h2>地図を表示するには</h2>
				<pre class="brush: objc; title: ; notranslate">
- (void)setup
{
    CGRect screen = [[UIScreen mainScreen] bounds];
    MKMapView *mapView = [[MKMapView alloc] initWithFrame:screen];
    [[self view] addSubview:mapView];
    [mapView release];

    MKCoordinateRegion  region;
    region.center = [location coordinate];
    region.span.latitudeDelta = 0.005;
    region.span.longitudeDelta = 0.005;
    [mapView setRegion:region animated:YES];
}
</pre>
				<p>とすれば、locationで指定した座標に移動します。</p>
				<h2>現在地を取得するには</h2>
				<p>MKReverseGeocoderDelegateを実装し</p>
				<pre class="brush: objc; title: ; notranslate">
- (void)setup
{
    MKReverseGeocoder *reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:[location coordinate]];
    [reverseGeocoder setDelegate:self];
    [reverseGeocoder start];
}

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
    NSLog(@&quot;%@&quot;, [placemark title]);
}
</pre>
				<p>とすることで取得することができます。<br />
				すべてのAPIが非常にシンプルに作られているので、使用するのは非常に簡単です。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cocoalife.net/2010/01/post_498.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C的？？？Geohash</title>
		<link>http://www.cocoalife.net/2010/01/post_485.html</link>
		<comments>http://www.cocoalife.net/2010/01/post_485.html#comments</comments>
		<pubDate>Sun, 24 Jan 2010 00:14:06 +0000</pubDate>
		<dc:creator>milkcocoa</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://www.cocoalife.net/?p=485</guid>
		<description><![CDATA[以下はObjective-C的？？？Geohash &#124; アクトインディ技術部隊報告書と同様のものです。 先日chibaさんがGeohashをdecodeするものをCLで書いていらしたので、それを微妙に参考にしながらCocoaのCoreLocationのCLLocationにgeohashをencode/decodeするメソッド追加してみました。 本当はビット演算がしたいのですが、文字列処理の方が自分には単純で簡単だったため、とりあえず今回は文字列処理にしてみました。 我ながらひどいコードだと思いますので、これからリファクタリングをしていきたいところです。 [CLLocation+Geohash.h] [CLLocation+Geohash.m] NSStringでかなり遅いcharacterAtIndexを使いまくっている。 参考 Geohash &#8211; Wikipedia, the free encyclopedia GeoHashのdecodeのアルゴリズムの解説します &#038; ScalaのGeoHashライブラリを作ってみました(仮) &#8211; ゆろよろ日記]]></description>
			<content:encoded><![CDATA[				<p>以下は<a target="_blank" href="http://tech.actindi.net/3472988345">Objective-C的？？？Geohash | アクトインディ技術部隊報告書</a>と同様のものです。</p>
				<p>先日<a target="_blank" href="http://tech.actindi.net/3472464385">chibaさんがGeohashをdecodeするものをCLで書いていらした</a>ので、それを微妙に参考にしながらCocoaのCoreLocationのCLLocationにgeohashをencode/decodeするメソッド追加してみました。</p>
				<p>本当はビット演算がしたいのですが、文字列処理の方が自分には単純で簡単だったため、とりあえず今回は文字列処理にしてみました。</p>
				<p>我ながらひどいコードだと思いますので、これからリファクタリングをしていきたいところです。</p>
				<p>[CLLocation+Geohash.h]</p>
				<pre class="brush: objc; title: ; notranslate">
#import &lt;CoreLocation/CoreLocation.h&gt;
#import &lt;Foundation/Foundation.h&gt;

@interface CLLocation(Geohash)

@property (nonatomic, readonly)   NSString    *geohash;

+ (CLLocation *)locationFromGeohash:(NSString *)aGeohash;

@end
</pre>
				<p>[CLLocation+Geohash.m]</p>
				<pre class="brush: objc; title: ; notranslate">
#import &quot;CLLocation+Geohash.h&quot;

#include &lt;math.h&gt;

NSString *int_to_binary(NSUInteger input)
{
    if (input == 1 || input == 0)
    {
        return [NSString stringWithFormat:@&quot;%d&quot;, input];
    }

    return [NSString stringWithFormat:@&quot;%@%d&quot;, int_to_binary(input / 2), input % 2];
}

double parse_binary(NSString *binary, double max, double min)
{
    double mid = 0.0;

    for (NSUInteger i = 0; i &lt; [binary length]; ++i)
    {
        if ([binary characterAtIndex:i] == '1')
        {
            min = mid;
        }
        else
        {
            max = mid;
        }

        mid = (max + min) / 2;
    }

    return mid;
}

NSUInteger binary_to_int(NSString *input)
{
    NSUInteger result, length;

    result = 0;
    length = [input length];

    for (NSUInteger i = 0; i &lt; length; ++i)
    {
        if ([input characterAtIndex:i] == '1')
        {
            result += pow(2, length - i - 1);
        }
    }

    return result;
}

NSString * generate_binary(double input, double max, double min, int cutoff)
{
    NSMutableString     *result;
    double              mid;

    result = [NSMutableString string];
    for (int i = 0; i &lt; cutoff; ++i)
    {
        mid = (max + min) / 2;

        if (input &gt; mid)
        {
            [result appendString:@&quot;1&quot;];
            min = mid;
        }
        else
        {
            [result appendString:@&quot;0&quot;];
            max = mid;
        }
    }

    return [NSString stringWithString:result];
}

@implementation CLLocation(Geohash)

- (NSString *)geohash
{
    int cutoff = 15;
    NSString *base32_characters  = @&quot;0123456789bcdefghjkmnpqrstuvwxyz&quot;;

    NSString            *bin_lat, *bin_lng;
    NSMutableString     *bin_packed, *result;

    bin_lat = generate_binary([self coordinate].latitude, 90.0, -90.0, cutoff);
    bin_lng = generate_binary([self coordinate].longitude, 180.0, -180.0, cutoff);

    bin_packed = [NSMutableString string];

    for (int i = 0; i &lt; [bin_lat length]; ++i)
    {
        [bin_packed appendFormat:@&quot;%c%c&quot;, [bin_lng characterAtIndex:i], [bin_lat characterAtIndex:i]];
    }

    result = [NSMutableString string];

    // extract by 5-bit.
    for (int i = 0; i &lt; [bin_packed length] / 5; ++i)
    {
        NSUInteger index;
        index = binary_to_int([bin_packed substringWithRange:NSMakeRange(i * 5, 5)]);
        [result appendFormat:@&quot;%c&quot;, [base32_characters characterAtIndex:index]];
    }

    return result;
}

+ (CLLocation *)locationFromGeohash:(NSString *)aGeohash
{
    NSString *base32_characters  = @&quot;0123456789bcdefghjkmnpqrstuvwxyz&quot;;

    NSMutableString *bin_packed, *bin_lat, *bin_lng;

    bin_packed = [NSMutableString string];

    for (NSUInteger i = 0; i &lt; [aGeohash length]; ++i)
    {
        NSString *character;
        character = [[NSMutableString stringWithFormat:@&quot;%c&quot;, [aGeohash characterAtIndex:i]] lowercaseString];

        for (NSUInteger j = 0; j &lt; [base32_characters length]; ++j)
        {
            if ([character isEqualToString:[NSString stringWithFormat:@&quot;%c&quot;, [base32_characters characterAtIndex:j]]])
            {
                NSMutableString *binary;
                binary = [NSMutableString stringWithFormat:@&quot;%@&quot;, int_to_binary(j)];

                NSUInteger length = [binary length];
                for (NSUInteger k = 0; k &lt; 5 - length; ++k)
                {
                    [binary insertString:@&quot;0&quot; atIndex:0];
                }

                [bin_packed appendString:binary];
                break;
            }
        }
    }

    bin_lat = [NSMutableString string];
    bin_lng = [NSMutableString string];

    for (NSUInteger i = 0; i &lt; [bin_packed length]; ++i)
    {
        if (i % 2)
        {
            // a latitude is composed of odd bits.
            [bin_lat appendFormat:@&quot;%c&quot;, [bin_packed characterAtIndex:i]];
        }
        else
        {
            // a longitude is composed of even bits.
            [bin_lng appendFormat:@&quot;%c&quot;, [bin_packed characterAtIndex:i]];
        }
    }

    return [[CLLocation alloc] initWithLatitude:parse_binary(bin_lat, 90.0, -90.0)
                                      longitude:parse_binary(bin_lng, 180.0, -180.0)];
}

@end
</pre>
				<p>NSStringでかなり遅いcharacterAtIndexを使いまくっている。</p>
				<h2>参考</h2>
				<p><a href="http://en.wikipedia.org/wiki/Geohash">Geohash &#8211; Wikipedia, the free encyclopedia<br />
				<a target="_blank" href="http://d.hatena.ne.jp/yuroyoro/20100115/1263526125">GeoHashのdecodeのアルゴリズムの解説します &#038; ScalaのGeoHashライブラリを作ってみました(仮) &#8211; ゆろよろ日記</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cocoalife.net/2010/01/post_485.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

