<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7725244335912421956</id><updated>2024-10-05T11:01:26.387+09:00</updated><category term="/"/><category term="NSDate NSComparisonResult compare isEqualToDate"/><title type='text'>C開発者によるiPhoneプログラミング</title><subtitle type='html'>C,C++,C#開発者によるObjective-Cプログラミング日記。</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>84</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-1897550173985221032</id><published>2013-03-15T17:25:00.000+09:00</published><updated>2013-03-15T17:50:33.547+09:00</updated><title type='text'>独自クラスの配列をソートする</title><content type='html'>独自の型を持つ要素の配列をソートするには、NSArrayクラスの「&lt;span style=&quot;background-color: yellow;&quot;&gt;sortedArrayUsingSelector&lt;/span&gt;」メソッドを使います。&lt;br /&gt;
&lt;br /&gt;
例えば、TestClassという独自のクラスを配列にしてソートさせたい場合、以下のようにします。&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
@interface TestClass : NSObject {&lt;br /&gt;
@public&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSString *scale;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: yellow;&quot;&gt;-(NSComparisonResult)compare_func:(TestClass*)a; // ソート時に呼ばれます&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
@property (nonatomic, retain) NSString *scale;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@implementation TestClass&lt;br /&gt;
@synthesize scale;&lt;br /&gt;
&lt;br /&gt;
-(id)init&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;self = [super init];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (self) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;scale = @&quot;ちゅうくらい&quot;;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return self;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-(id)initWithString:(NSString*)str&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;self = [super init];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (self) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;scale = [str retain];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return self;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: yellow;&quot;&gt;-(NSComparisonResult)compare_func:(TestClass*)a // ソート時に呼ばれます&lt;/span&gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if ([self.scale isEqualToString:@&quot;ちゅうくらい&quot;]) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if ([a.scale isEqualToString:@&quot;おおきい&quot;]) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return NSOrderedAscending;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} else if ([a.scale isEqualToString:@&quot;ちゅうくらい&quot;]) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return NSOrderedSame;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} else {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return NSOrderedDescending;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;} else if ([self.scale isEqualToString:@&quot;おおきい&quot;]) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return NSOrderedDescending;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;} else if ([self.scale isEqualToString:@&quot;ちいさい&quot;]) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return NSOrderedAscending;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return NSOrderedAscending;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
ソート処理の中身とかは別にどうでも良いのですが、重要なのはソート処理に使うメソッドを用意しておくということです。&lt;br /&gt;
このクラスを配列にしてソートさせるには、以下のようにします。&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
// 独自クラス(TestClass)の配列を生成&lt;br /&gt;
NSArray *test_array = [[NSArray arrayWithObjects:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[[[TestClass alloc] init] autorelease]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;, [[[TestClass alloc] initWithString:@&quot;おおきい&quot;] autorelease]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;, [[[TestClass alloc] initWithString:@&quot;ちいさい&quot;] autorelease]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;, nil] retain];&lt;br /&gt;
&lt;br /&gt;
// ソート&lt;br /&gt;
NSArray *sorted_array = [test_array sortedArrayUsingSelector:@selector(&lt;span style=&quot;background-color: yellow;&quot;&gt;compare_func:&lt;/span&gt;)];&lt;br /&gt;
&lt;br /&gt;
// 結果を出力&lt;br /&gt;
for (TestClass *tc in sorted_array) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; NSLog(@&quot;%@&quot;, tc.scale);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
NSArrayクラスの「sortedArrayUsingSelector」メソッドの引数に独自クラスに実装したソート用のメソッド（compare_func:）を指定することで、NSArrayがソート時に呼び出してくれるようになります。&lt;br /&gt;
&lt;br /&gt;
結果は以下のようになります。&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
ちいさい&lt;br /&gt;
ちゅうくらい&lt;br /&gt;
おおきい&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NSArrayクラスの「&lt;span style=&quot;background-color: white;&quot;&gt;sortedArrayUsingSelector&lt;/span&gt;」メソッドは要素となるクラスにソート処理を実装しなければなりませんが、「&lt;span style=&quot;background-color: yellow;&quot;&gt;sortedArrayUsingFunction&lt;/span&gt;」メソッドはソート処理を外部の関数に指定することができます。&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
// ソート処理を配列要素ではなく、外部の関数に定義&lt;br /&gt;
NSInteger compare_func(TestClass *a, TestClass *b, void* context)&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if ([a.scale isEqualToString:@&quot;ちゅうくらい&quot;]) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if ([b.scale isEqualToString:@&quot;おおきい&quot;]) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return NSOrderedAscending;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} else if ([b.scale isEqualToString:@&quot;ちゅうくらい&quot;]) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return NSOrderedSame;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} else {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return NSOrderedDescending;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;} else if ([a.scale isEqualToString:@&quot;おおきい&quot;]) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return NSOrderedDescending;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;} else if ([a.scale isEqualToString:@&quot;ちいさい&quot;]) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return NSOrderedAscending;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return NSOrderedAscending;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main (int argc, const char * argv[])&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSArray *test_array = [[NSArray arrayWithObjects:[[[TestClass alloc] init] autorelease]&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp; , [[[TestClass alloc] initWithString:@&quot;おおきい&quot;] autorelease]&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp; , [[[TestClass alloc] initWithString:@&quot;ちいさい&quot;] autorelease]&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp; , nil] retain];&lt;br /&gt;
&lt;span style=&quot;background-color: yellow;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSArray *sorted_array = [test_array sortedArrayUsingFunction:compare_func context:NULL];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for (TestClass *tc in sorted_array) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NSLog(@&quot;%@&quot;, tc.scale);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
結果は先の結果と同じになります。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/1897550173985221032/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2013/03/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/1897550173985221032'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/1897550173985221032'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2013/03/blog-post.html' title='独自クラスの配列をソートする'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-5739310759401949345</id><published>2013-03-14T10:30:00.002+09:00</published><updated>2013-03-14T10:30:54.167+09:00</updated><title type='text'>NSArrayのソート</title><content type='html'>NSArrayをソートするには、sortedArrayUsingComparatorメソッドを使います。&lt;br /&gt;
&lt;br /&gt;
数値を降順にソートする場合&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSArray *num_array = [NSArray arrayWithObjects:[NSNumber numberWithInt:0]&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt; &amp;nbsp;, [NSNumber numberWithInt:3]&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt; &amp;nbsp;, [NSNumber numberWithInt:2]&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt; &amp;nbsp;, [NSNumber numberWithInt:4]&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt; &amp;nbsp;, [NSNumber numberWithInt:1]&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt; &amp;nbsp;, [NSNumber numberWithInt:7]&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt; &amp;nbsp;, [NSNumber numberWithInt:10]&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt; &amp;nbsp;, [NSNumber numberWithInt:9]&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt; &amp;nbsp;, [NSNumber numberWithInt:8]&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt; &amp;nbsp;, [NSNumber numberWithInt:5]&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt; &amp;nbsp;, nil];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSArray *sorted_array = &lt;span style=&quot;background-color: yellow;&quot;&gt;[num_array sortedArrayUsingComparator:^NSComparisonResult(NSNumber *a, NSNumber *b) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: yellow;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return b.intValue - a.intValue; // ソート&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: yellow;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for (NSNumber *aNum in sorted_array) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NSLog(@&quot;sorted_num:%@&quot;, aNum);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
上記のブロック関数内のaとbを入れ替えてやれば昇順にソートさせることもできます。&lt;br /&gt;
&lt;br /&gt;
結果は以下のようになります。&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
sorted_num:10&lt;br /&gt;
sorted_num:9&lt;br /&gt;
sorted_num:8&lt;br /&gt;
sorted_num:7&lt;br /&gt;
sorted_num:5&lt;br /&gt;
sorted_num:4&lt;br /&gt;
sorted_num:3&lt;br /&gt;
sorted_num:2&lt;br /&gt;
sorted_num:1&lt;br /&gt;
sorted_num:0&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;br /&gt;
文字を降順にソートする場合&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSArray *str_array = [NSArray arrayWithObjects:@&quot;A&quot;, @&quot;E&quot;, @&quot;B&quot;, @&quot;Z&quot;, @&quot;C&quot;, @&quot;F&quot;, @&quot;D&quot;, nil];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;sorted_array = &lt;span style=&quot;background-color: yellow;&quot;&gt;[str_array sortedArrayUsingComparator:^NSComparisonResult(NSString *a, NSString *b) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: yellow;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return [b compare:a]; // ソート&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: yellow;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for (NSString *str in sorted_array) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NSLog(@&quot;sorted_str:%@&quot;, str);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
上記のブロック関数内のaとbを入れ替えてやれば昇順にソートさせることもできます。&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
結果は以下のようになります。&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
sorted_str:Z&lt;br /&gt;
sorted_str:F&lt;br /&gt;
sorted_str:E&lt;br /&gt;
sorted_str:D&lt;br /&gt;
sorted_str:C&lt;br /&gt;
sorted_str:B&lt;br /&gt;
sorted_str:A&lt;br /&gt;
&lt;/div&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;br /&gt;
他にもsortedArrayUsingFunctionやsortedArrayUsingSelector等あります。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/5739310759401949345/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2013/03/nsarray.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/5739310759401949345'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/5739310759401949345'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2013/03/nsarray.html' title='NSArrayのソート'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-4944729495512396498</id><published>2013-03-01T11:44:00.000+09:00</published><updated>2013-03-01T13:36:37.227+09:00</updated><title type='text'>Cabochaを呼び出す[mac]</title><content type='html'>（この記事はiphoneではなく、[mac]のみ対応です。）&lt;br /&gt;
&lt;br /&gt;
日本語の構文解析ツールにCabochaというものがあります。&lt;br /&gt;
CabochaにはC言語から呼び出す為のAPIが用意されています。&lt;br /&gt;
C言語用のAPIですが、もちろんObjective-Cからも呼び出すことが可能です。&lt;br /&gt;
&lt;br /&gt;
Cabochaがインストールされていることが前提ですが（インストール方法は他のサイトでいろいろ出てきますので・・）、その利用方法はまず、コマンドラインから次のコマンドを入力します。&lt;br /&gt;
&lt;br /&gt;
cabocha-config --cflags&lt;br /&gt;
&lt;br /&gt;
上記でCabochaヘッダのインストールパスを取得できます。&lt;br /&gt;
私の環境では&lt;br /&gt;
&lt;br /&gt;
-I/usr/local/include&lt;br /&gt;
&lt;br /&gt;
となりました。&lt;br /&gt;
ヘッダのインストールパスをxcodeのBuild Settingsの[SearchPaths]の[Header Search Paths]ところに設定します。その際、-Iは不要なので「/usr/local/include」と設定します。&lt;br /&gt;
&lt;br /&gt;
これでCabochaのAPIを利用する準備ができたので、あとは利用するソースからヘッダを引き込む為に&lt;br /&gt;
&lt;br /&gt;
#import &quot;cabocha.h&quot;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
を書き、以下のようにすればCabochaが呼び出せます。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;const char *p = [@&quot;これは日本語のテストです。&quot; UTF8String];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;const char *result;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// Cabocha起動&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;char *argv[] = {&quot;cabocha&quot;, &quot;-f1&quot;};&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;c = cabocha_new(2, argv);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;result = cabocha_sparse_tostr(c, p);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSString *strResult = [NSString stringWithCString:result encoding:NSUTF8StringEncoding];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;cabocha_destroy(c);&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
cabocha_newの１番めの引数はargvの要素数を設定します。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/4944729495512396498/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2013/03/cabocha.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/4944729495512396498'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/4944729495512396498'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2013/03/cabocha.html' title='Cabochaを呼び出す[mac]'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-311994207147748030</id><published>2013-02-27T14:35:00.002+09:00</published><updated>2013-02-27T14:35:30.275+09:00</updated><title type='text'>NSDictionary(plist)をバイナリで保存する</title><content type='html'>NSDictionaryはwriteToFileで簡単に保存できますが、XMLファイルで保存される為、サイズが非常に大きくなってしまう場合があります。&lt;br /&gt;
&lt;br /&gt;
バイナリファイルで保存するには、NSPropertyListSerializationを使って以下のようにします。&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// 辞書を生成&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// 辞書に追加&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[dic setValue:@&quot;1&quot; forKey:@&quot;TEST&quot;];&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// ストリームを生成&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSOutputStream *outstream = [NSOutputStream outputStreamToFileAtPath:@&quot;./testDic&quot; append:NO];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[outstream open];&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// オープン&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// 辞書をバイナリでファイルに保存&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[NSPropertyListSerialization writePropertyList:dic toStream:outstream format:NSPropertyListBinaryFormat_v1_0 options:NSPropertyListImmutable error:&amp;amp;error];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (error != nil) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NSLog(@&quot;Error:%@&quot;, error.description);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[outstream close];&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// クローズ&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
保存したものを読み込むには以下のようにします。&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;dic = [NSDictionary dictionaryWithContentsOfFile:@&quot;./testDic&quot;];&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/311994207147748030/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2013/02/nsdictionaryplist.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/311994207147748030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/311994207147748030'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2013/02/nsdictionaryplist.html' title='NSDictionary(plist)をバイナリで保存する'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-1139486736353538788</id><published>2013-02-27T10:12:00.000+09:00</published><updated>2013-02-27T10:35:41.513+09:00</updated><title type='text'>NSArrayとNSDictionaryの検索速度</title><content type='html'>NSArrayとNSDictionaryを生成して検索速度を比較してみました。&lt;br /&gt;
結果、NSDictionaryの検索速度の方が速いようです。&lt;br /&gt;
ハッシュ（連想配列）なので当たり前と言えば当たり前ですが。。&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// 計測用データ作成&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSMutableArray *array = [[NSMutableArray alloc] init];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for (int i = 0 ; i &amp;lt; 500000; i++ ) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NSString *val = [NSString stringWithFormat:@&quot;%d&quot;, i];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;[dic setValue:[NSString stringWithFormat:@&quot;%ld&quot;, i] forKey:val];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;[array addObject:val];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSLog(@&quot;辞書検索Start&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSDate *startTime = [NSDate date];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSString *strTest = @&quot;400000&quot;;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSString *num = [dic valueForKey:strTest];&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;// 辞書を検索&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSTimeInterval interval = [[NSDate date] timeIntervalSinceDate:startTime];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSLog(@&quot;辞書検索Stop at:%lf&quot;, interval);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (num) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NSLog(@&quot;There is %@ in the dictionary&quot;, strTest);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;} else {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NSLog(@&quot;There is not %@ in the dictionary&quot;, strTest);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSLog(@&quot;配列検索Start&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;startTime = [NSDate date];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;unsigned long idx = [array indexOfObject:strTest];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;interval = [[NSDate date] timeIntervalSinceDate:startTime];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSLog(@&quot;配列検索Stop at:%lf&quot;, interval);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (idx != NSNotFound) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NSLog(@&quot;There is %@ in the dictionary&quot;, strTest);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;} else {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NSLog(@&quot;There is not %@ in the dictionary&quot;, strTest);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSLog(@&quot;配列検索2Start&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;startTime = [NSDate date];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;BOOL hasString = [array containsObject:strTest];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;interval = [[NSDate date] timeIntervalSinceDate:startTime];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;NSLog(@&quot;配列検索2Stop at:%lf&quot;, interval);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (hasString) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NSLog(@&quot;There is %@ in the dictionary&quot;, strTest);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;} else {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NSLog(@&quot;There is not %@ in the dictionary&quot;, strTest);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
結果は以下のようになりました。(iPhoneでの計測ではなく、Mac上で計測しました。)&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
辞書検索Start&lt;br /&gt;
辞書検索Stop at:0.000017&lt;br /&gt;
here is 400000 in the dictionary&lt;br /&gt;
配列検索Start&lt;br /&gt;
配列検索Stop at:0.036717&lt;br /&gt;
here is 400000 in the dictionary&lt;br /&gt;
配列検索2Start&lt;br /&gt;
配列検索2Stop at:0.037023&lt;br /&gt;
here is 400000 in the dictionary&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
配列検索ではindexOfObjectによる検索とcontainsObjectによる検索を計測しましたが、どちらも大差は無さそうです。&lt;br /&gt;
ちなみに、検索する要素を&quot;400000&quot;から&quot;250000&quot;にすると以下のようになりました。&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;br /&gt;
辞書検索Start&lt;br /&gt;
辞書検索Stop at:0.000050&lt;br /&gt;
There is 250000 in the dictionary&lt;br /&gt;
配列検索Start&lt;br /&gt;
配列検索Stop at:0.022836&lt;br /&gt;
There is 250000 in the dictionary&lt;br /&gt;
配列検索2Start&lt;br /&gt;
配列検索2Stop at:0.022718&lt;br /&gt;
There is 250000 in the dictionary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;br /&gt;
ハッシュの検索はほぼ大差ない速度（むしろ若干遅くなっている）ですが、配列の検索では要素位置が上のほうにある為か高速に検索が行えました。&lt;br /&gt;
&lt;br /&gt;
結論としては、&lt;br /&gt;
・ハッシュ(NSDictionary)は要素の数や位置に関わらずほぼ同一速度で検索が行える。&lt;br /&gt;
・配列(NSArray)は要素数や要素位置に応じて検索速度が変わる&lt;br /&gt;
・indexOfObjectとcontainsObjectによる検索は速度に大差なし&lt;br /&gt;
&lt;br /&gt;
というところでしょうか。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/1139486736353538788/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2013/02/nsarraynsdictionary.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/1139486736353538788'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/1139486736353538788'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2013/02/nsarraynsdictionary.html' title='NSArrayとNSDictionaryの検索速度'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-6008256133010070846</id><published>2012-12-10T15:18:00.000+09:00</published><updated>2012-12-14T12:15:35.414+09:00</updated><title type='text'>アドレスブック（連絡先）からの情報取得</title><content type='html'>アドレスブック（連絡先）へアクセスするには以下の様にします。&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;// &lt;/span&gt;アドレスブックを生成&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;ABAddressBookRef&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt; book = &lt;/span&gt;ABAddressBookCreateWithOptions&lt;span class=&quot;s3&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;// &lt;/span&gt;アドレスブックのレコード配列を取得&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;CFArrayRef&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt; records = &lt;/span&gt;ABAddressBookCopyArrayOfAllPeople&lt;span class=&quot;s3&quot;&gt;(book);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;// &lt;/span&gt;配列の要素の数だけ繰り返す&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s5&quot;&gt;int&lt;/span&gt; i = &lt;span class=&quot;s5&quot;&gt;0&lt;/span&gt; ; i &amp;lt; &lt;span class=&quot;s6&quot;&gt;CFArrayGetCount&lt;/span&gt;(records) ; i++) {&lt;/div&gt;
&lt;div class=&quot;p5&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; // 1&lt;span class=&quot;s7&quot;&gt;レコード取得&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;ABRecordRef&lt;/span&gt; record = &lt;span class=&quot;s6&quot;&gt;CFArrayGetValueAtIndex&lt;/span&gt;(records, i);&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p5&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;// &lt;span class=&quot;s7&quot;&gt;名を取得&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;NSString&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt; *firstName = (&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;NSString&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;*)&lt;/span&gt;ABRecordCopyValue&lt;span class=&quot;s3&quot;&gt;(record, &lt;/span&gt;kABPersonFirstNameProperty&lt;span class=&quot;s3&quot;&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;if&lt;/span&gt; (firstName == &lt;span class=&quot;s5&quot;&gt;nil&lt;/span&gt;) {&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;firstName = &lt;span class=&quot;s8&quot;&gt;@&quot;&quot;&lt;/span&gt;;&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s9&quot;&gt;// &lt;/span&gt;&lt;span class=&quot;s10&quot;&gt;無ければ空文字に&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p5&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;// &lt;span class=&quot;s7&quot;&gt;氏を取得&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;NSString&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt; *lastName = (&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;NSString&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;*)&lt;/span&gt;ABRecordCopyValue&lt;span class=&quot;s3&quot;&gt;(record, &lt;/span&gt;kABPersonLastNameProperty&lt;span class=&quot;s3&quot;&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;if&lt;/span&gt; (lastName == &lt;span class=&quot;s5&quot;&gt;nil&lt;/span&gt;) {&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;lastName = &lt;span class=&quot;s8&quot;&gt;@&quot;&quot;&lt;/span&gt;;&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s9&quot;&gt;// &lt;/span&gt;&lt;span class=&quot;s10&quot;&gt;無ければ空文字に&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p5&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;// &lt;span class=&quot;s7&quot;&gt;氏名を生成&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;NSString&lt;/span&gt; *name = [&lt;span class=&quot;s4&quot;&gt;NSString&lt;/span&gt; &lt;span class=&quot;s6&quot;&gt;stringWithFormat&lt;/span&gt;:&lt;span class=&quot;s8&quot;&gt;@&quot;%@ %@&quot;&lt;/span&gt;, lastName, firstName];&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;NSLog(@&quot;%@&quot;,&amp;nbsp;name);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;if&lt;/span&gt; (firstName != &lt;span class=&quot;s5&quot;&gt;nil&lt;/span&gt;) {&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s6&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;s6&quot;&gt;CFRelease&lt;/span&gt;(firstName);&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;if&lt;/span&gt; (lastName != &lt;span class=&quot;s5&quot;&gt;nil&lt;/span&gt;) {&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s6&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;s6&quot;&gt;CFRelease&lt;/span&gt;(lastName);&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;// &lt;/span&gt;レコードから電話番号の取得&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;ABMultiValueRef&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt; tels = &lt;/span&gt;ABRecordCopyValue&lt;span class=&quot;s3&quot;&gt;(record, &lt;/span&gt;kABPersonPhoneProperty&lt;span class=&quot;s3&quot;&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;if&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt; (&lt;/span&gt;ABMultiValueGetCount&lt;span class=&quot;s3&quot;&gt;(tels)) {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;s4&quot;&gt;NSString&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt; *tel = (&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;NSString&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;*)&lt;/span&gt;ABMultiValueCopyValueAtIndex&lt;span class=&quot;s3&quot;&gt;(tels, &lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;s3&quot;&gt;NSLog(@&quot;%@&quot;,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;tel);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s6&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;s6&quot;&gt;CFRelease&lt;/span&gt;(tel);&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;}&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
}&lt;span class=&quot;Apple-tab-span&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt; &lt;/span&gt;CFRelease&lt;span class=&quot;s3&quot;&gt;(book);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s6&quot;&gt;CFRelease&lt;/span&gt;(records);&lt;/div&gt;
&lt;hr /&gt;
&lt;br /&gt;
「ABRecordCopyValue」のパラメータで指定するkABPersonFirstNameProperty等で連絡先から何を取得するかを指定します。&lt;br /&gt;
その他プロパティには以下のものがあります。&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;kABPersonFirstName&lt;/td&gt;&lt;td&gt;ファーストネーム&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonLastName&lt;/td&gt;&lt;td&gt;ラストネーム&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonMiddleName&lt;/td&gt;&lt;td&gt;ミドルネーム&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonPrefixProperty&lt;/td&gt;&lt;td&gt;プレフィックス&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonSuffixProperty&lt;/td&gt;&lt;td&gt;サフィックス&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonNicknameProperty&lt;/td&gt;&lt;td&gt;ニックネーム&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonFirstNamePhoneticProperty&lt;/td&gt;&lt;td&gt;ファーストネームの読み&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonLastNamePhoneticProperty&lt;/td&gt;&lt;td&gt;ラストネームの読み&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonMiddleNamePhoneticProperty&lt;/td&gt;&lt;td&gt;ミドルネームの読み&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonOrganizationProperty&lt;/td&gt;&lt;td&gt;組織&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonJobTitleProperty&lt;/td&gt;&lt;td&gt;役職&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonDepartmentProperty&lt;/td&gt;&lt;td&gt;部門&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonDepartmentProperty&lt;/td&gt;&lt;td&gt;Eメール&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonBirthdayProperty&lt;/td&gt;&lt;td&gt;誕生日&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonNoteProperty&lt;/td&gt;&lt;td&gt;メモ&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonCreationDateProperty&lt;/td&gt;&lt;td&gt;作成日&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonModificationDateProperty&lt;/td&gt;&lt;td&gt;更新日&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonAddressProperty&lt;/td&gt;&lt;td&gt;住所&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonDateProperty&lt;/td&gt;&lt;td&gt;日付&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonKindProperty&lt;/td&gt;&lt;td&gt;種別&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonPhoneProperty&lt;/td&gt;&lt;td&gt;電話番号&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonInstantMessageProperty&lt;/td&gt;&lt;td&gt;インスタントメッセージ&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonURLProperty&lt;/td&gt;&lt;td&gt;URL&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;kABPersonRelatedNamesProperty&lt;/td&gt;&lt;td&gt;関係&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
また、アドレスブックから取得した各種情報はCFReleaseで解放する必要があります。(ARCを使用していない場合)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/6008256133010070846/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2012/12/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/6008256133010070846'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/6008256133010070846'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2012/12/blog-post.html' title='アドレスブック（連絡先）からの情報取得'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-822492178715652391</id><published>2012-07-06T01:15:00.000+09:00</published><updated>2012-07-06T01:15:29.346+09:00</updated><title type='text'>Apple Developer登録の更新方法</title><content type='html'>アップルのデベロッパー登録は、１年ごとに更新する必要があります。&lt;br /&gt;
&lt;br /&gt;
毎年やる度に試行錯誤することになってしまうので、備忘録として記録しておきます。&lt;br /&gt;
&lt;br /&gt;
各種証明書の概念は&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;a href=&quot;http://technical-iphone.blogspot.jp/2012/06/ios.html&quot; target=&quot;_blank&quot;&gt;こちらの説明&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;に譲るとして、以下の流れで各種証明書を更新する必要があります。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. アプリケーション→ユーティリティにあるキーチェーンアクセス.appを起動し、「iPhone Developer」証明書と「iPhone Distribution」証明書を削除する。（ログインタブとシステムタブにあります。念のため削除後に検索バーから「iPhone」で検索をかけて旧い証明書が検索されないか確認する。旧いのが残っていると、後でビルド時に証明書関連のエラーが出て時間を浪費することになるので注意。）&lt;br /&gt;
&lt;br /&gt;
2. 「キーチェーンアクセス」→「証明書アシスタント」→「認証局に証明書を要求」後、「ユーザーのメールアドレス」、「通称」を入力、（「CAのメールアドレス」は空でも良い）要求の処理に「ディスクに保存」をチェック、「鍵ペア情報を生成」はチェック無しで「続ける」をクリックし、「CertificateSigningRequest.certSigningRequest」証明書をデスクトップに書き出し。&lt;br /&gt;
&lt;br /&gt;
3. アップルのデベロッパーサイトを開き、Certificatesから「Request Certificate」をクリック。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5gUvv6GFfC472U41NQVzxbIcvvgh06HPX_C4USr99oJT7b5jDy7KugIWT3xj51i0skM97ofEMWVgY3BKUnCmsJh484pbLSzp_G6EMGJoeTsS3wJTAQMGdIvf8LZlvREuEQhRAEMRAEHU/s1600/3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5gUvv6GFfC472U41NQVzxbIcvvgh06HPX_C4USr99oJT7b5jDy7KugIWT3xj51i0skM97ofEMWVgY3BKUnCmsJh484pbLSzp_G6EMGJoeTsS3wJTAQMGdIvf8LZlvREuEQhRAEMRAEHU/s1600/3.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
4. 画面下部の「ファイルを選択」をクリックする。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfsquXrF5hH7N8HhGcEVIOjqUi14nEtUF4Xhm_f5hR-VrwQxD0AT3Ql7yiukyngAwedeYi-E-Xg_wizoWUMcj19BuDE5fysuRRfP4w2clV57JmKVbuvcF75_VSrpNQAB8rMMw-ap2VrEQ/s1600/4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfsquXrF5hH7N8HhGcEVIOjqUi14nEtUF4Xhm_f5hR-VrwQxD0AT3Ql7yiukyngAwedeYi-E-Xg_wizoWUMcj19BuDE5fysuRRfP4w2clV57JmKVbuvcF75_VSrpNQAB8rMMw-ap2VrEQ/s1600/4.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
5. 2で書き出した証明書ファイルを選択し、「submit」ボタンをクリックする。&lt;br /&gt;
&lt;br /&gt;
6. 証明書の「Status」が「Pending」になるので、他のタブ（Distribution等）を選択後、適当な時間待ってから「Development」タブを選択する。&lt;br /&gt;
&lt;br /&gt;
7. 「Status」が「Issued」に変わり、「Download」ボタンが押せるようになっているので、クリックして証明書（ios_development.cer）をダウンロードする。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5u32QiRDd-VsOJxPW8oRZJFaQsc8EuzPIxhbFTLHqL9kgPqc0rrAYZjyd6EthZSM2EcLzaUkTaUKWcdlii1anoN5PEuNaXpvXJKGvgZBrA6VUGFlo4Ksk-jkqRm-4izl2CcAkPCie0RI/s1600/7.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5u32QiRDd-VsOJxPW8oRZJFaQsc8EuzPIxhbFTLHqL9kgPqc0rrAYZjyd6EthZSM2EcLzaUkTaUKWcdlii1anoN5PEuNaXpvXJKGvgZBrA6VUGFlo4Ksk-jkqRm-4izl2CcAkPCie0RI/s1600/7.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
8. ダウンロードした証明書（ios_development.cer）ファイルをダブルクリックする。（キーチェーンアクセス.appで新しい有効期限の証明書になっていることを確認する。）&lt;br /&gt;
&lt;br /&gt;
9. 「Distribution」タブをクリックし、「Revoke」をクリック。確認画面で「OK」を押して期限切れ間近（または既に期限切れになっている）Distribution用証明書を削除する。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbhJrU81UT5U8YVaJsdXkRr1py9qhANT3yL3OEVk_lZ__reaDdcwonvzri0tZjrNVWyEiXYgmR3BeuxPahzGBIPAYH6qiy_K5gnWFLwahfJpxkXcvnjAv4WNDs-Zo7Lme-pOwUqiUeVxc/s1600/9.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbhJrU81UT5U8YVaJsdXkRr1py9qhANT3yL3OEVk_lZ__reaDdcwonvzri0tZjrNVWyEiXYgmR3BeuxPahzGBIPAYH6qiy_K5gnWFLwahfJpxkXcvnjAv4WNDs-Zo7Lme-pOwUqiUeVxc/s1600/9.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
10. 「Request Certificate」ボタンが押せるようになっているのでクリックする。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipda07yM9XzKDtSedJsMON-KJyjn0QFjr1QIaeywUJfU-uRoH8XGKD43Rlzbj26LV-amg5uznl6FoE2FDT9h6Ntu0kZyp3e2tJN_lKFqynmVyK12dhsu-mTALzQfoHMybOh3Lb7W7m2tA/s1600/10.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipda07yM9XzKDtSedJsMON-KJyjn0QFjr1QIaeywUJfU-uRoH8XGKD43Rlzbj26LV-amg5uznl6FoE2FDT9h6Ntu0kZyp3e2tJN_lKFqynmVyK12dhsu-mTALzQfoHMybOh3Lb7W7m2tA/s1600/10.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
11. 「ファイルを選択」をクリックする。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzoOiWClsTUFpe-E_KZrEuSVgVDrajsvQoLCdvoa6TyslX7JNlhdSqy0gpEUhrJgLQ-1_I8qhXCXWHVMnzZ3NBg_nCMdVSVFS6e8tCmSnx3ZUNJhvpeKPaiT2u-taKW7zkppzWtXHdVs8/s1600/11.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzoOiWClsTUFpe-E_KZrEuSVgVDrajsvQoLCdvoa6TyslX7JNlhdSqy0gpEUhrJgLQ-1_I8qhXCXWHVMnzZ3NBg_nCMdVSVFS6e8tCmSnx3ZUNJhvpeKPaiT2u-taKW7zkppzWtXHdVs8/s1600/11.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
12. 2で書き出したファイルを選択し、「submit」ボタンをクリックする。&lt;br /&gt;
&lt;br /&gt;
13. 証明書の「Status」が「Pending」になるので、他のタブ（Development等）を選択後、適当な時間待ってから「Distribution」タブを選択する。&lt;br /&gt;
&lt;br /&gt;
14. 「Status」が「Issued」に変わり、「Download」ボタンが押せるようになっているので、クリックして証明書（ios_distribution.cer）をダウンロードする。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPmOxaheEzNSTEY83em7WmW4Fp9MtTDt7vGIpUzeZJejP5re9wBKcQos3XrgiaD7zHCCPGtXMgtoEoTyJRFbYZnQlDgO8ygcpJXXnKI2w1S56Nmck1f7ryVLuzQYp0f2xJ2-rb5LeDa_I/s1600/14.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPmOxaheEzNSTEY83em7WmW4Fp9MtTDt7vGIpUzeZJejP5re9wBKcQos3XrgiaD7zHCCPGtXMgtoEoTyJRFbYZnQlDgO8ygcpJXXnKI2w1S56Nmck1f7ryVLuzQYp0f2xJ2-rb5LeDa_I/s1600/14.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
15. ダウンロードした証明書（ios_distribution.cer）ファイルをダブルクリックする。（キーチェーンアクセス.appで新しい有効期限の証明書になっていることを確認する。）&lt;br /&gt;
&lt;br /&gt;
16. 以上で終了です。App IDとDevice IDは変更する必要はありませんが、プロビジョニングプロファイルは再作成＆ダウンロードする必要があります。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/822492178715652391/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2012/07/apple-developer.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/822492178715652391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/822492178715652391'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2012/07/apple-developer.html' title='Apple Developer登録の更新方法'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5gUvv6GFfC472U41NQVzxbIcvvgh06HPX_C4USr99oJT7b5jDy7KugIWT3xj51i0skM97ofEMWVgY3BKUnCmsJh484pbLSzp_G6EMGJoeTsS3wJTAQMGdIvf8LZlvREuEQhRAEMRAEHU/s72-c/3.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-7873742905086916176</id><published>2012-06-04T18:14:00.000+09:00</published><updated>2012-06-04T18:19:22.498+09:00</updated><title type='text'>iOSアプリの証明書まとめ</title><content type='html'>iOSアプリを実機で動作させるには、iOS Developer Centerでいくつか証明書を作成・登録する必要があります。&lt;br /&gt;
以前、アップルのマニュアルなどを見て設定は行っているのですが、１年ごとの更新の度に忘れてしまうのでまとめておきます。&lt;br /&gt;
&lt;br /&gt;
まずは概要からです。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZ4-AHW3Jish9igWBlkTB3tqxj2o5vn85hI2S3x5qCftVs9kNCJFgEzyda-7i7NJe0ddIqtkm1tIKENO8IYpfuF3BWIijcHDd1GIg5r21eZdPqX0AcEti5XW1_HvTOkQjB9Qkw1NPTgq0/s1600/iOS%E3%82%A2%E3%83%95%E3%82%9A%E3%83%AA%E8%A8%BC%E6%98%8E%E6%9B%B8%E6%A6%82%E8%A6%81.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZ4-AHW3Jish9igWBlkTB3tqxj2o5vn85hI2S3x5qCftVs9kNCJFgEzyda-7i7NJe0ddIqtkm1tIKENO8IYpfuF3BWIijcHDd1GIg5r21eZdPqX0AcEti5XW1_HvTOkQjB9Qkw1NPTgq0/s640/iOS%E3%82%A2%E3%83%95%E3%82%9A%E3%83%AA%E8%A8%BC%E6%98%8E%E6%9B%B8%E6%A6%82%E8%A6%81.png&quot; width=&quot;637&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
以下、上の概要の手順を、１つずつ少し詳しく書いたものです。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
まず、証明書署名要求ファイルの登録です。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh429KgIc4i2np823tb92yYleqo9bLmXLO_OXXwTKpMC_wG5Fv4gCla-XzqhzrP0tg13wrgEASISh3otjDDKCJUeb5E389q9CWEKEP7Mv9DU2srbjY5kMcxlO4gYXzqAbgqgPk-NS33zhk/s1600/%E8%A8%BC%E6%98%8E%E6%9B%B8%E3%81%AE%E6%B5%81%E3%82%8C1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;346&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh429KgIc4i2np823tb92yYleqo9bLmXLO_OXXwTKpMC_wG5Fv4gCla-XzqhzrP0tg13wrgEASISh3otjDDKCJUeb5E389q9CWEKEP7Mv9DU2srbjY5kMcxlO4gYXzqAbgqgPk-NS33zhk/s640/%E8%A8%BC%E6%98%8E%E6%9B%B8%E3%81%AE%E6%B5%81%E3%82%8C1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
次に、デバイスの登録です。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJaGMI62WX0L32oFohFn6FG6YBcSBCnWa659vgN-OabRq4h20QWZQbefQTguJ_fDXY7YCXOFpK5oLBdqzw-WWzi6Sox0unI7I0mNEa1qwDQXSmWvi-1kCqMJhPXf9wo6hWdGxXjX0gfiU/s1600/%E8%A8%BC%E6%98%8E%E6%9B%B8%E3%81%AE%E6%B5%81%E3%82%8C2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;384&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJaGMI62WX0L32oFohFn6FG6YBcSBCnWa659vgN-OabRq4h20QWZQbefQTguJ_fDXY7YCXOFpK5oLBdqzw-WWzi6Sox0unI7I0mNEa1qwDQXSmWvi-1kCqMJhPXf9wo6hWdGxXjX0gfiU/s640/%E8%A8%BC%E6%98%8E%E6%9B%B8%E3%81%AE%E6%B5%81%E3%82%8C2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
次に、アプリケーションの登録です。&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn1ARvHF4_T8UjwFgPbKHrzl78mI6_mAdvAYt7IjSZIGT8yFcfxEw4Ixjn8HxzBE8PgQNvlWxkEtD8pbo5oL5Z5ekk742FWdqvr3dQDrqqBDeI0GAnCd2zrTYi8ZkoCYPha8rlAUK_tmo/s1600/%E8%A8%BC%E6%98%8E%E6%9B%B8%E3%81%AE%E6%B5%81%E3%82%8C3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;368&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn1ARvHF4_T8UjwFgPbKHrzl78mI6_mAdvAYt7IjSZIGT8yFcfxEw4Ixjn8HxzBE8PgQNvlWxkEtD8pbo5oL5Z5ekk742FWdqvr3dQDrqqBDeI0GAnCd2zrTYi8ZkoCYPha8rlAUK_tmo/s640/%E8%A8%BC%E6%98%8E%E6%9B%B8%E3%81%AE%E6%B5%81%E3%82%8C3.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
次に、プロビジョニングプロファイルの登録です。&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdKslPggoax6Sy-GNFKgkWnp4OGUZaWj9j7_hp6I-zrYTEpUT_GQ91gggNECD-2lLlDB5ouQj3e_gTlG_ZU8rLu6Bk_bgT5S0WFv3q1-WB4sSS-qlI6ulbKkO9D4MFYrMGPMd6VZeAUlE/s1600/%E8%A8%BC%E6%98%8E%E6%9B%B8%E3%81%AE%E6%B5%81%E3%82%8C4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;368&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdKslPggoax6Sy-GNFKgkWnp4OGUZaWj9j7_hp6I-zrYTEpUT_GQ91gggNECD-2lLlDB5ouQj3e_gTlG_ZU8rLu6Bk_bgT5S0WFv3q1-WB4sSS-qlI6ulbKkO9D4MFYrMGPMd6VZeAUlE/s640/%E8%A8%BC%E6%98%8E%E6%9B%B8%E3%81%AE%E6%B5%81%E3%82%8C4.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&amp;nbsp;最後に、ビルドします。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizlJO_kmiXi24cGIck7EI4hwGedEpwHq3vqt6aTg9PiC0sScD1h7lpcRPfSdvvEnKjLCa6FQYKT3ITnOJ5lF12F7cjDuGrnWkinEyGql8KvvbH9g725is7OpAsjXPO-GjL0mEOAigRaAs/s1600/%E8%A8%BC%E6%98%8E%E6%9B%B8%E3%81%AE%E6%B5%81%E3%82%8C5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;288&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizlJO_kmiXi24cGIck7EI4hwGedEpwHq3vqt6aTg9PiC0sScD1h7lpcRPfSdvvEnKjLCa6FQYKT3ITnOJ5lF12F7cjDuGrnWkinEyGql8KvvbH9g725is7OpAsjXPO-GjL0mEOAigRaAs/s640/%E8%A8%BC%E6%98%8E%E6%9B%B8%E3%81%AE%E6%B5%81%E3%82%8C5.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/7873742905086916176/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2012/06/ios.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/7873742905086916176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/7873742905086916176'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2012/06/ios.html' title='iOSアプリの証明書まとめ'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZ4-AHW3Jish9igWBlkTB3tqxj2o5vn85hI2S3x5qCftVs9kNCJFgEzyda-7i7NJe0ddIqtkm1tIKENO8IYpfuF3BWIijcHDd1GIg5r21eZdPqX0AcEti5XW1_HvTOkQjB9Qkw1NPTgq0/s72-c/iOS%E3%82%A2%E3%83%95%E3%82%9A%E3%83%AA%E8%A8%BC%E6%98%8E%E6%9B%B8%E6%A6%82%E8%A6%81.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-8839676656967244586</id><published>2012-01-20T08:47:00.000+09:00</published><updated>2012-01-20T08:47:46.868+09:00</updated><title type='text'>isaって何？</title><content type='html'>デバッグをしていると、よくisaという変数を目にすることがあります。&lt;br /&gt;
isaは、NSObjectが持っている構造体で、スーパークラスへのポインタや、メソッドの情報を保持しています。&lt;br /&gt;
&lt;br /&gt;
例えば、NSMutableStringはNSStringクラスを継承したクラスですが、NSMutableStringのisa変数の中にNSStringへのポインタを保持しています。&lt;br /&gt;
&lt;br /&gt;
また、NSMutableStringは「stringByAppendingString:」というメソッドを持っていますが、このメソッドの情報を以下の様にNSMutableStringのisa変数に格納しています。&lt;br /&gt;
&lt;br /&gt;
セレクタ　メソッド名の文字列&lt;br /&gt;
　22　　　stringByAppendingString:&lt;br /&gt;
　33　　　メソッドＡ&lt;br /&gt;
　44　　　メソッドＢ&lt;br /&gt;
　・　　　　　・&lt;br /&gt;
　・　　　　　・&lt;br /&gt;
　・　　　　　・&lt;br /&gt;
&lt;br /&gt;
上の例のセレクタは説明の為適当な値です。また、セレクタはchar*型ですが、実際にはint型の数値が入ります。&lt;br /&gt;
Objective-Cのコンパイラは、メソッドの呼び出しを以下の様にC言語のコードに展開します。&lt;br /&gt;
&lt;br /&gt;
[objA stringByAppendingString:objB];&lt;br /&gt;
　　↓&lt;br /&gt;
objc_msgSend(objA, 22, objB);&lt;br /&gt;
&lt;br /&gt;
「objc_msgSend」関数は、objAにあるセレクタ22に対してobjBを送信してくれるC言語の関数です。&lt;br /&gt;
objc_msgSend関数はobjAの中にあるisa変数を参照して、指定されたセレクタ（22）を検索します。そしてそこにあったメソッドにobjBを渡すとともに呼び出してくれます。&lt;br /&gt;
ここで該当するセレクタがisaの中に見つからなかった場合は、スーパークラスであるNSStringのポインタを取得し、NSStringのisaに対して同様の処理を行います。&lt;br /&gt;
NSStringでも見つからなければ更にその継承元・・という風に辿っていき、最終的にNSObjectでも見つからなければ例外を発生させるという流れになります。&lt;br /&gt;
&lt;br /&gt;
このような処理を行うことで、Objective-Cではプログラム実行時に動的にメソッドを入れ替えることがし易くなっているのです。&lt;br /&gt;
&lt;br /&gt;
ただし、Ｃ言語のように直にポインタを呼び出すとかではないので動作は遅くなるはずです。また、Ｃ＋＋言語と比べてもObjective-Cは検索処理などが行わる為、動作はかなり遅くなるはずです。（Ｃ＋＋言語はクラスメソッドのジャンプテーブルを参照するのでＣ言語より数ステップ程度動作は遅くなります。）&lt;br /&gt;
多分ですが、メソッド呼び出しだけを見る限りＣ言語よりも数十倍〜数百倍は遅くなっているはずです。（遅さを補っても余りある利便性があるということです。）</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/8839676656967244586/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2012/01/isa.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/8839676656967244586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/8839676656967244586'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2012/01/isa.html' title='isaって何？'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-5933520007269815466</id><published>2011-11-23T12:53:00.001+09:00</published><updated>2011-11-23T12:55:01.293+09:00</updated><title type='text'>UISearchBarに画像を設定する</title><content type='html'>UISearchBarに画像を設定するには、UISearchBarBackgroundビューを入れ替えてやります。&lt;br /&gt;
&lt;br /&gt;
&lt;hr&gt;// searchBarはUISearchBarのインスタンス&lt;br /&gt;
for (UIView *v in searchBar.subviews) {&lt;br /&gt;
if ([NSStringFromClass(v.class) isEqualToString:@&quot;UISearchBarBackground&quot;]) {&lt;br /&gt;
[v removeFromSuperview];&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
UIImage *img = [UIImage imageNamed:@&quot;custom_searchbar&quot;];&lt;br /&gt;
UIImageView *iv = [[UIImageView alloc] initWithImage:img];&lt;br /&gt;
[searchBar insertSubview:iv atIndex:0];&lt;br /&gt;
[iv release];&lt;br /&gt;
&lt;hr&gt;&lt;br /&gt;
１．UISearchBarのサブビューからUISearchBarBackgroundを探し、サーチバーから削除します。&lt;br /&gt;
２．UISearchBarBackgroundが合った場所にUIImageViewを挿入すれば画像が表示されるようになります。&lt;br /&gt;
　　（custom_searchbarは背景に使用する画像ファイル名です。）</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/5933520007269815466/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2011/11/uisearchbar.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/5933520007269815466'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/5933520007269815466'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2011/11/uisearchbar.html' title='UISearchBarに画像を設定する'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-5283408834598211944</id><published>2011-07-12T11:49:00.000+09:00</published><updated>2013-04-13T17:27:24.002+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="/"/><title type='text'>UILocalNotification</title><content type='html'>UILocalNotificationは、アプリケーションが終了した状態でも指定時間になったらメッセージを表示する等の動作を行わせることができる機能です。&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
// ローカル通知を作成&lt;br /&gt;
UILocalNotification *ln = [[UILocalNotification alloc] init];&lt;br /&gt;
&lt;br /&gt;
NSDate *dt;&lt;br /&gt;
dt = [NSDate dateWithTimeIntervalSinceNow:60]; // 60秒後に表示&lt;br /&gt;
&lt;br /&gt;
// 通知時刻を設定&lt;br /&gt;
[ln setFireDate:dt];&lt;br /&gt;
&lt;br /&gt;
// タイムゾーンを設定&lt;br /&gt;
[ln setTimeZone:[NSTimeZone localTimeZone]];&lt;br /&gt;
&lt;br /&gt;
// メッセージを設定&lt;br /&gt;
[ln setAlertBody:@&quot;起きて&quot;];&lt;br /&gt;
&lt;br /&gt;
// サウンド設定&lt;br /&gt;
[ln setSoundName:UILocalNotificationDefaultSoundName];&lt;br /&gt;
&lt;br /&gt;
// ボタンタイトルの設定&lt;br /&gt;
[ln setAlertAction:@&quot;Open&quot;];&lt;br /&gt;
&lt;br /&gt;
// ローカル通知を登録&lt;br /&gt;
[[UIApplication sharedApplication] scheduleLocalNotification:ln];&lt;br /&gt;
&lt;br /&gt;
[ln release];&lt;br /&gt;
&lt;hr /&gt;
上記例の処理をアプリに行わせて終了させると、アプリが動作していなくても６０秒後に「起きて」というメッセージが表示されるようになります。&lt;br /&gt;
&lt;br /&gt;
サウンド設定にはサウンドファイル名を拡張子付きで指定しますが、再生時間が３０秒未満、かつ以下の形式でないと無効となり、システムのデフォルトサウンドが再生されてしまうので注意が必要です。&lt;br /&gt;
&lt;br /&gt;
●リニアPCM&lt;br /&gt;
● MA4（IMA/ADPCM）&lt;br /&gt;
● µLaw&lt;br /&gt;
● aLaw&lt;br /&gt;
&lt;br /&gt;
上記ファイルはaiff, caf, wavのファイルです。&lt;br /&gt;
&lt;br /&gt;
また、applicationIconBadgeNumberプロパティに任意の数字を指定することで、メールアプリなどでよく見られるようなバッヂが表示されるようになります。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/5283408834598211944/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2011/07/uilocalnotification.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/5283408834598211944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/5283408834598211944'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2011/07/uilocalnotification.html' title='UILocalNotification'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-7996619831681358420</id><published>2011-07-07T11:46:00.002+09:00</published><updated>2011-07-07T11:50:15.360+09:00</updated><title type='text'>特殊フォルダのパスを取得する</title><content type='html'>ドキュメントフォルダなどのパスの一覧を取得するには、NSSearchPathForDirectoriesInDomain関数を使用します。&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;NSArray * NSSearchPathForDirectoriesInDomains (&lt;br /&gt;
&amp;nbsp;&amp;nbsp; NSSearchPathDirectory directory,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; NSSearchPathDomainMask domainMask,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; BOOL expandTilde&lt;br /&gt;
);&lt;br /&gt;
&lt;hr /&gt;&lt;br /&gt;
NSSearchPathDirectoryは、取得するパスの種類を指定します。&lt;br /&gt;
&lt;table border=&quot;2&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;定数&lt;/td&gt;&lt;td&gt;内容&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSApplicationDirectory&lt;/td&gt;&lt;td&gt;アプリケーションディレクトリ&lt;br /&gt;
（/Applications）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSDemoApplicationDirectory&lt;/td&gt;&lt;td&gt;デモバージョンアプリケーション&lt;br /&gt;
ディレクトリ&lt;br /&gt;
（/Demos）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSDeveloperApplicationDirectory&lt;/td&gt;&lt;td&gt;開発用アプリケーションディレクトリ&lt;br /&gt;
（/Developer/Applications）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSAdminApplicationDirectory&lt;/td&gt;&lt;td&gt;システムとネットワーク管理者用&lt;br /&gt;
アプリケーションディレクトリ&lt;br /&gt;
（/Administration）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSLibraryDirectory&lt;/td&gt;&lt;td&gt;ライブラリディレクトリ&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSDeveloperDirectory&lt;/td&gt;&lt;td&gt;開発ツールディレクトリ（/Developer）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSUserDirectory&lt;/td&gt;&lt;td&gt;ユーザディレクトリ（/Users）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSDocumentationDirectory&lt;/td&gt;&lt;td&gt;ドキュメンテーションディレクトリ&lt;br /&gt;
（/Library/Documentation）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSDocumentDirectory&lt;/td&gt;&lt;td&gt;ドキュメントディレクトリ&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSCoreServiceDirectory&lt;/td&gt;&lt;td&gt;コアサービスディレクトリ&lt;br /&gt;
（/System/Libary/CoreServices）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSAutosavedInformationDirectory&lt;/td&gt;&lt;td&gt;自動保存ディレクトリ&lt;br /&gt;
（~/Library/Autosave Information）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSDesktopDirectory&lt;/td&gt;&lt;td&gt;デスクトップ&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSCachesDirectory&lt;/td&gt;&lt;td&gt;キャッシュディレクトリ&lt;br /&gt;
（Library/Caches）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSApplicationSupportDirectory&lt;/td&gt;&lt;td&gt;アプリケーションサポート&lt;br /&gt;
ディレクトリ&lt;br /&gt;
（Library/Application Support）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSDownloadsDirectory&lt;/td&gt;&lt;td&gt;ダウンロードディレクトリ&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSInputMethodsDirectory&lt;/td&gt;&lt;td&gt;インプットメソッドディレクトリ&lt;br /&gt;
（Library/Input Methods）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSMoviesDirectory&lt;/td&gt;&lt;td&gt;ムービーディレクトリ（~/Movies）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSMusicDirectory&lt;/td&gt;&lt;td&gt;ミュージックディレクトリ（~/Musics）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSPicturesDirectory&lt;/td&gt;&lt;td&gt;ピクチャディレクトリ（~/Picture）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSPrinterDescriptionDirectory&lt;/td&gt;&lt;td&gt;プリンタ情報ディレクトリ&lt;br /&gt;
（Library/Printers/PPDs）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSSharedPublicDirectory&lt;/td&gt;&lt;td&gt;パブリックディレクトリ（~/Public）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSPreferencePanesDirectory&lt;/td&gt;&lt;td&gt;プリファレンスペインディレクトリ&lt;br /&gt;
（~/PreferencePanes）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSItemReplacementDirectory&lt;/td&gt;&lt;td&gt;「NSFileManager」クラスの&lt;br /&gt;
「URLForDirectory:inDomain&lt;br /&gt;
:appropriateForURL:create:error:」&lt;br /&gt;
メソッドと組み合わせて使用する定数&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSAllApplicationsDirectory&lt;/td&gt;&lt;td&gt;全アプリケーションディレクトリ&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSAllLibrariesDirectory&lt;/td&gt;&lt;td&gt;全ライブラリディレクトリ&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt; &lt;/table&gt;&lt;br /&gt;
&lt;br /&gt;
NSSearchPathDomainMaskは、取得するパスの範囲を指定します。&lt;br /&gt;
&lt;table border=&quot;2&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;定数&lt;/td&gt;&lt;td&gt;内容&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSUserDomainMask&lt;/td&gt;&lt;td&gt;ユーザーのホームディレクトリ&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSLocalDomainMask&lt;/td&gt;&lt;td&gt;ローカルマシン内&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSNetworkDomainMask&lt;/td&gt;&lt;td&gt;ネットワーク内（/Network等）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSSystemDomainMask&lt;/td&gt;&lt;td&gt;システム内（/System）&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;NSAllDomainsMask&lt;/td&gt;&lt;td&gt;全てのドメイン&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt; &lt;/table&gt;&lt;br /&gt;
&lt;br /&gt;
expandTildeは、パスが長い場合にチルダをフルパスにするかを指定します。&lt;br /&gt;
&lt;br /&gt;
NSString文字の配列がNSArrayに返却されます。</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/7996619831681358420/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2011/07/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/7996619831681358420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/7996619831681358420'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2011/07/blog-post.html' title='特殊フォルダのパスを取得する'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-8480523994089356778</id><published>2011-07-07T10:52:00.001+09:00</published><updated>2011-07-07T10:53:11.068+09:00</updated><title type='text'>アプリで作成したドキュメントをMacと共有できるようにする</title><content type='html'>iPhoneアプリで作成したドキュメントをMacと共有するには、アプリのInfo.plistファイルを編集します。&lt;br /&gt;
&lt;br /&gt;
ビルド設定の「Info」タグに行を追加し、「Application supports iTunes file sharing」 を追加し、タイプをBOOL型にしてYESにします。&lt;br /&gt;
&lt;br /&gt;
これでiTunesのAppタグからアプリのドキュメントを共有できるようになります。</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/8480523994089356778/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2011/07/mac.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/8480523994089356778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/8480523994089356778'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2011/07/mac.html' title='アプリで作成したドキュメントをMacと共有できるようにする'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-5063092804535080332</id><published>2011-07-05T10:50:00.002+09:00</published><updated>2011-10-04T21:11:30.191+09:00</updated><title type='text'>codesign failed</title><content type='html'>アップルのデベロッパー登録は１年毎に更新する必要がありますが、この時アップルの説明書の通りに更新しても、いざ新しくビルドを行おうとする時に以下のエラーが出てハマる場合があります。&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;iPhone Developer: ・・・・・・・・: ambiguous (matches &quot;iPhone Developer: ・・・・・・・・・&quot; in /Library/Keychains/System.keychain and &quot;iPhone Developer: ・・・・・・・・・&quot; in /Users/・・・・・/Library/Keychains/login.keychain)&lt;br /&gt;
Command /usr/bin/codesign failed with exit code 1&lt;br /&gt;
&lt;hr /&gt;・・・の部分は開発者ごとに異なります。&lt;br /&gt;
&lt;br /&gt;
この原因はキーチェインに以前登録した古い開発者用の証明書が残っていて、「証明書ユーティリティが新しいのと古いのとどっちを使っていいのか分からない」のが原因みたいです。&lt;br /&gt;
この場合、 【アプリケーション】→【ユーティリティ】にあるキーチェーンアクセスを起動してみると、☓印がついた証明書（期限切れの証明書）があると思うので、削除します。&lt;br /&gt;
&lt;br /&gt;
☓印がついた証明書が見えない場合もあり（私はこれでハマりました）、この場合は検索ボックスで「iphone」と検索すると表示されるようになります。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
【追記】&lt;br /&gt;
xcode4.0.1を使っている時にエラーが出る場合もあります。&lt;br /&gt;
この場合、xcode4.1がひっそりとリリースされていて、をれを使えば直る場合があります。&lt;br /&gt;
バージョン４以降は【product】→【edit scheme】でArchiveのBuild ActionをDistributionに変えておくのも忘れないようにしましょう。&lt;br /&gt;
&lt;br /&gt;
【更に追記】&lt;br /&gt;
同じcodesignエラーですが、エラーの内容が以下の様になる場合があります。&lt;br /&gt;
&lt;hr /&gt;&lt;blockquote&gt;    &lt;code&gt;Code sign &lt;span class=&quot;highlight&quot;&gt;error&lt;/span&gt;: The identity &quot;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/iPhone&quot;&gt;&lt;span class=&quot;highlight&quot;&gt;iPhone&lt;/span&gt;&lt;/a&gt; &lt;span class=&quot;highlight&quot;&gt;Developer&lt;/span&gt;&quot; &lt;span class=&quot;highlight&quot;&gt;doesn&#39;t&lt;/span&gt; &lt;span class=&quot;highlight&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;highlight&quot;&gt;any&lt;/span&gt; &lt;span class=&quot;highlight&quot;&gt;valid&lt;/span&gt; certificate / private &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/key&quot;&gt;&lt;span class=&quot;highlight&quot;&gt;key&lt;/span&gt;&lt;/a&gt; &lt;span class=&quot;highlight&quot;&gt;pair&lt;/span&gt; in the default &lt;span class=&quot;highlight&quot;&gt;key&lt;/span&gt;chain.&lt;/code&gt; &lt;/blockquote&gt;&lt;hr /&gt;これはキーチェインがデフォルトになっていないからだそうです。&lt;br /&gt;
【アプリケーション】→【ユーティリティ】でキーチェインアクセスを起動し、左上の窓からログインを右クリック。【キーチェーン”ログイン”をデフォルトにする】を選択するとエラーが出なくなります。</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/5063092804535080332/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2011/07/codesign-failed.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/5063092804535080332'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/5063092804535080332'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2011/07/codesign-failed.html' title='codesign failed'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-7382901676173998932</id><published>2011-06-04T10:26:00.001+09:00</published><updated>2011-06-04T10:44:19.993+09:00</updated><title type='text'>実機とシミュレータで挙動を変える</title><content type='html'>ごくまれにですが、実機では動くのにシミュレータでは動かない命令があります。&lt;br /&gt;
&lt;br /&gt;
例えば、iAd広告を表示する時、ADBannerViewのrequiredContentSizeIdentifiersプロパティを設定しようとすると何故かシミュレータでは動きません。&lt;br /&gt;
&lt;br /&gt;
このような場合等に実機とシミュレータで挙動を切り替える必要が出てきますが、シミュレータ上だけで有効になるデファイン値が用意されています。 &lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;#ifndef TARGET_IPHONE_SIMULATOR&lt;br /&gt;
・&lt;br /&gt;
・&lt;br /&gt;
#endif&lt;br /&gt;
&lt;hr /&gt;#ifndefで囲んだ部分は、シミュレータ用のビルドではビルドされません。</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/7382901676173998932/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2011/06/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/7382901676173998932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/7382901676173998932'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2011/06/blog-post.html' title='実機とシミュレータで挙動を変える'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-4084626627855265464</id><published>2011-04-18T01:09:00.000+09:00</published><updated>2011-04-18T01:09:15.482+09:00</updated><title type='text'>Subviewを最前面・再背面に移動する</title><content type='html'>特定のSubviewを最前面に移動する場合、bringSubviewToFrontメソッドを使用します。&lt;br /&gt;
逆に、再背面に移動したい場合、sendSubviewToBackメソッドを使用します。&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;[self.view bringSubviewToFront:最前面に移動したいView];&lt;br /&gt;
[self.view sendSubviewToBack:最背面に移動したいView]&lt;br /&gt;
&lt;hr /&gt;</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/4084626627855265464/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2011/04/subview.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/4084626627855265464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/4084626627855265464'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2011/04/subview.html' title='Subviewを最前面・再背面に移動する'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-7211026147548701489</id><published>2011-03-25T11:34:00.001+09:00</published><updated>2011-03-25T11:38:58.449+09:00</updated><title type='text'>GameKitで小数を送信する</title><content type='html'>GameKitでスコアやランキングデータを送信する時、Appleのドキュメントでは整数(int64)のデータを送信する方法しか載っていないので、タイムなどの小数(45.67秒等)を送信したい場合は一瞬戸惑います。&lt;br /&gt;
&lt;br /&gt;
小数を送信する場合、NSNumberクラスを使用します。&lt;br /&gt;
NSNumberクラスはBoolやdouble,Int型などのprimitive型をオブジェクトにしたい場合に使用する便利なクラスです。&lt;br /&gt;
&lt;br /&gt;
&lt;hr&gt;-(void)reportScores:(double)score forCategory:(NSString*)category&lt;br /&gt;
{&lt;br /&gt;
scoreReporter = [[[GKScore alloc] initWithCategory:category] autorelease];&lt;br /&gt;
NSNumber *numScore = [NSNumber numberWithDouble:round(score * 100)];&lt;br /&gt;
scoreReporter.value = numScore.intValue;&lt;br /&gt;
[scoreReporter reportScoreWithCompletionHandler:^(NSError* error) {&lt;br /&gt;
if (error != nil) {&lt;br /&gt;
// エラー処理&lt;br /&gt;
return;&lt;br /&gt;
}&lt;br /&gt;
}];&lt;br /&gt;
}&lt;br /&gt;
&lt;hr&gt;&lt;br /&gt;
Appleのドキュメントに載っているスコア送信例を、double型を送信するように変更してあります。&lt;br /&gt;
上の例では、少数以下２桁を送信する例です。&lt;br /&gt;
引数のdouble型scoreを整数にしたいので１００倍してNSNumber型のオブジェクトにします。&lt;br /&gt;
その後、そのint値(64ビット値)をGKScoreオブジェクトに設定しています。&lt;br /&gt;
勿論、iTunesでリーダーボードのスコア設定をDecimal小数２桁等、小数を扱うように設定しておく必要はあります。&lt;br /&gt;
&lt;br /&gt;
後はAppleドキュメントに載っている様にランキング受信処理でGKScoreのformattedValueプロパティを参照すれば、iTunesで設定したフォーマットでNSString文字列が取得できます。</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/7211026147548701489/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2011/03/gamekit.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/7211026147548701489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/7211026147548701489'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2011/03/gamekit.html' title='GameKitで小数を送信する'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-8835836925399862581</id><published>2011-03-02T23:03:00.000+09:00</published><updated>2011-03-02T23:03:38.561+09:00</updated><title type='text'>IOS4以降のアニメーション</title><content type='html'>IOS4以降のアニメーションは、[UIView animateWithDulation:delay:options:animations:completion:]を使います。IOS4以降でも従来のアニメーションは行えるようですが、非推奨となってしまったようです。&lt;br /&gt;
もっと簡易的に使えるメソッドもありますが、これだけ覚えておけば事足りるかもしれません。&lt;br /&gt;
&lt;br /&gt;
&lt;HR&gt; [UIView animateWithDuration:0.5&lt;br /&gt;
        delay:0&lt;br /&gt;
      options:UIViewAnimationOptionCurveEaseOut&lt;br /&gt;
      animations:^{&lt;br /&gt;
       button.alpha = 0.0; // UIButtonインスタンスを徐々に透明に&lt;br /&gt;
      }&lt;br /&gt;
      completion:^(BOOL finished){&lt;br /&gt;
       button.alpha = 1.0f; // buttonを現す&lt;br /&gt;
      }];&lt;br /&gt;
&lt;HR&gt;&lt;br /&gt;
第一引数はアニメーションにかける時間を指定します。上記例では０．５秒間でボタンを徐々に透明にしていきます。&lt;br /&gt;
delayはアニメーションを開始する時間を指定します。上記例では０なので即時アニメーション開始です。&lt;br /&gt;
optionsはアニメーションの動作のオプションです。上記例ではEaseOutで徐々に速度を落としてアニメーションをさせています。&lt;br /&gt;
animationsが実際のアニメーションの指定です。&lt;br /&gt;
completionはアニメーションが終了した時に呼び出される処理です。上記例では徐々に透明になったボタンの姿を再度現すようにしています。</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/8835836925399862581/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2011/03/ios4.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/8835836925399862581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/8835836925399862581'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2011/03/ios4.html' title='IOS4以降のアニメーション'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-4740509256854318728</id><published>2011-02-19T00:42:00.000+09:00</published><updated>2011-02-19T00:42:59.075+09:00</updated><title type='text'>プロビジョニングプロファイル</title><content type='html'>プロビジョニング等セキュリティ関連の情報をなんとなくまとめてみました。&lt;br /&gt;
&lt;br /&gt;
&lt;TABLE border=&quot;1&quot;&gt;&lt;TBODY&gt;
&lt;TR&gt;&lt;TD&gt;ID/プロファイル&lt;/TD&gt;&lt;TD&gt;内容&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;&lt;TD&gt;Bundle ID&lt;/TD&gt;&lt;TD&gt;アプリケーション固有のID。アプリケーション１つに１個。（例：com.apple.iTunes）&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;&lt;TD&gt;App ID&lt;/TD&gt;&lt;TD&gt;開発者がアプリケーションに「Push Notification」「in App Purchase」「Game Center」等へのアクセスを許可・禁止設定する為の挙動を管理するID。&lt;br /&gt;
キーチェインでのアクセス識別子となり、それぞれのアプリケーションの挙動を制御する。&lt;br /&gt;
アプリケーションの「挙動」について１つ付けられるIDの為、複数アプリケーションをまとめて指定できるワイルドカード指定が認められている。（例：com.apple.*）&lt;br /&gt;
ただし、GameCenter等のサービスを許可する時はワイルドカード指定は使えない。つまり各アプリケーションに１個のApp IDを付けなければならない。&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;&lt;TD&gt;プロビジョニングプロファイル&lt;/TD&gt;&lt;TD&gt;デバイスにインストールされて、実行時に正規のルートからインストールされたか確認するための情報を保持するファイル。（App ID/デバイスID/開発者IDを保持）&lt;/TD&gt;&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/4740509256854318728/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2011/02/blog-post_19.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/4740509256854318728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/4740509256854318728'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2011/02/blog-post_19.html' title='プロビジョニングプロファイル'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-2366747538414765597</id><published>2011-02-04T10:35:00.001+09:00</published><updated>2011-02-04T10:37:58.039+09:00</updated><title type='text'>メモリリークしない為に　その１</title><content type='html'>NSMutableArrayやNSArrayをautorelease以外でメモリ確保した場合、配列を解放しても要素の解放処理が呼び出されるわけではありません。&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;ar1 = [[NSMutableArray alloc] initWithObjects:@&quot;TEST1&quot;, @&quot;TEST2&quot;, @&quot;TEST3&quot;, nil];&lt;br /&gt;
ar2 = [[NSMutableArray alloc] initWithObjects:[SomeClass alloc]&lt;br /&gt;
, [SomeClass alloc]&lt;br /&gt;
, [SomeClass alloc], nil];&lt;br /&gt;
&lt;br /&gt;
arrays = [[NSArray alloc] initWithObjects:ar1, ar2, nil];&lt;br /&gt;
・&lt;br /&gt;
・&lt;br /&gt;
・&lt;br /&gt;
[arrays release]; // ar1 / ar2 とSomeClassがメモリリーク&lt;br /&gt;
&lt;hr /&gt;&lt;br /&gt;
上記例では、「arrays」の解放しか行っていないので、「ar1」「ar2」「SomeClass」が全てメモリリークとなります。&lt;br /&gt;
「TEST1」「TEST2」「TEST3」の文字列はautoreleaseされるので解放の必要はありません。&lt;br /&gt;
&lt;br /&gt;
要素を全て解放すればメモリリークしなくなります。&lt;br /&gt;
&lt;hr /&gt;[ar1 release]; // ar1を解放&lt;br /&gt;
// ar2の要素を解放&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; ar2.count; i++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; SomeClass* tmp = [ar2 objectAtIndex:i];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [tmp release];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
[ar2 release]; // ar2を解放  [arrays release]; // arraysを解放 &lt;br /&gt;
&lt;hr /&gt;</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/2366747538414765597/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2011/02/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/2366747538414765597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/2366747538414765597'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2011/02/blog-post.html' title='メモリリークしない為に　その１'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-1730219409419269355</id><published>2011-01-18T10:31:00.000+09:00</published><updated>2011-01-18T10:31:58.843+09:00</updated><title type='text'>UINavigationBar</title><content type='html'>UINavigationBarをUINavigationControllerではなく、UIViewController等に独自に実装する場合、以下のようにします。&lt;br /&gt;
&lt;br /&gt;
&lt;HR&gt; // ナビゲーションバーを生成&lt;br /&gt;
 UINavigationBar* navBarTop = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];&lt;br /&gt;
 navBarTop.alpha = 0.7f;&lt;br /&gt;
&lt;br /&gt;
 // ナビゲーションアイテムを生成&lt;br /&gt;
 UINavigationItem* title = [[UINavigationItem alloc] initWithTitle:@&quot;Title&quot;];&lt;br /&gt;
&lt;br /&gt;
 // 戻るボタンを生成&lt;br /&gt;
 UIBarButtonItem* btnItemBack = [[UIBarButtonItem alloc] initWithTitle:@&quot;Back&quot; style:UIBarButtonItemStyleBordered target:self action:@selector(clickBack:)];&lt;br /&gt;
&lt;br /&gt;
 // ナビゲーションアイテムの右側に戻るボタンを設置&lt;br /&gt;
 title.rightBarButtonItem = btnItemBack;&lt;br /&gt;
&lt;br /&gt;
 // ナビゲーションバーにナビゲーションアイテムを設置&lt;br /&gt;
 [navBarTop pushNavigationItem:title animated:YES];&lt;br /&gt;
&lt;br /&gt;
 // ビューにナビゲーションアイテムを設置&lt;br /&gt;
 [self.view addSubview:navBarTop];&lt;br /&gt;
&lt;HR&gt;&lt;br /&gt;
ナビゲーションアイテムを生成するときにタイトルを設定します。上記では「Title」という文字列を設定しました。これで画面上部に大きな文字で「Title」と表示されます。&lt;br /&gt;
&lt;br /&gt;
また、ナビゲーションアイテムにiPhoneアプリでよく見られる、画面右上と左上に表示されるボタンなどを設置します。&lt;br /&gt;
上記では右上に「戻る」ボタンを追加していますが、leftBarButtonItemプロパティに設置すれば、左上にも表示できます。&lt;br /&gt;
&lt;br /&gt;
UIBarButtonItemはカスタマイズ可能で、例えば&lt;br /&gt;
&lt;HR&gt; // segmentedControlはUISegementedControlのインスタンス&lt;br /&gt;
 UINavigationItem* title = [[UINavigationItem alloc] initWithCustomView:segmentedControl];&lt;br /&gt;
&lt;HR&gt;等とすれば、ナビゲーションバーの内部にUISegmentedControlのインスタンスや、その他スライダー等、いろいろと設置することが可能なようです。&lt;br /&gt;
&lt;br /&gt;
最後に「pushNavigationItem」でナビゲーションバーにアイテムを設置します。&lt;br /&gt;
「addSubview」を使いそうになりますので注意が必要です。</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/1730219409419269355/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2011/01/uinavigationbar.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/1730219409419269355'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/1730219409419269355'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2011/01/uinavigationbar.html' title='UINavigationBar'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-8240809966368030885</id><published>2011-01-09T10:04:00.000+09:00</published><updated>2011-01-09T10:04:08.997+09:00</updated><title type='text'>連続アニメーション</title><content type='html'>複数のアニメーションを連続して再生させるには、１つのアニメーションの終了を検知し、その後、続きのアニメーションを再生させます。&lt;br /&gt;
&lt;br /&gt;
アニメーションの終了は「setAnimationDidStopSelector:finished:context:」でアニメーションの終了メソッドを登録しておきます。&lt;br /&gt;
&lt;br /&gt;
&lt;HR&gt;  [UIView beginAnimations:@&quot;Animation1&quot; context:nil];&lt;br /&gt;
  [UIView setAnimationDuration:1.0];&lt;br /&gt;
  [UIView setAnimationDelegate:self];&lt;br /&gt;
  [UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];&lt;br /&gt;
  // imgViewはUIImageViewのインスタンス&lt;br /&gt;
  imgView.frame = CGRectMake(100, 200, imgView.frame.size.width, imgView.frame.size.height);&lt;br /&gt;
  [UIView commitAnimations];&lt;br /&gt;
・&lt;br /&gt;
・&lt;br /&gt;
・&lt;br /&gt;
- (void)animationFinished:(NSString *)animationID  finished:(BOOL)finished  context:(void *)context&lt;br /&gt;
{&lt;br /&gt;
 if ([animationID isEqualToString:@&quot;Animation1&quot;]) {&lt;br /&gt;
  [UIView beginAnimations:@&quot;Animation2&quot; context:nil];&lt;br /&gt;
  [UIView setAnimationDuration:0.5];&lt;br /&gt;
  [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];&lt;br /&gt;
  imgView.frame = CGRectMake(100, 50, imgView.frame.size.width, imgView.frame.size.height);&lt;br /&gt;
  [UIView commitAnimations];&lt;br /&gt;
&lt;HR&gt;&lt;br /&gt;
上記例では、イメージ（imgView）を１秒間かけて（100, 200）に移動した後、続いて０．５秒間かけて（100, 50）に移動させます。</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/8240809966368030885/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2011/01/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/8240809966368030885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/8240809966368030885'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2011/01/blog-post.html' title='連続アニメーション'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-6550342788491623078</id><published>2010-12-10T23:24:00.002+09:00</published><updated>2010-12-10T23:36:31.394+09:00</updated><title type='text'>変更される可能性のあるクラスのメソッドを呼び出す</title><content type='html'>任意のクラスのメソッドを呼び出すには下記のように&lt;br /&gt;
&lt;hr&gt;[testClass testMethod];&lt;br /&gt;
&lt;hr&gt;等と呼び出せば良いですが、例えば上記の「testClass」がプログラム実行中に動的に変更されてしまう場合は以下のようにします。&lt;br /&gt;
&lt;br /&gt;
&lt;hr&gt;objc_object* ptrClass = testClass;&lt;br /&gt;
SEL ptrMethod = @selector(testMethod:);&lt;br /&gt;
[ptrClass performSelector:ptrMethod withObject:パラメータ]; // 呼び出し&lt;br /&gt;
・&lt;br /&gt;
・&lt;br /&gt;
ptrClass = testClass2;  // 動的にクラスを変更&lt;br /&gt;
ptrMethod = @selector(testMethod2:); // 動的にメソッドを変更&lt;br /&gt;
[ptrClass performSelector:ptrMethod withObject:パラメータ]; // 呼び出し&lt;br /&gt;
&lt;hr&gt;&lt;br /&gt;
Ｃ＋＋に慣れた方であればポインタ変数を任意のクラスにキャストしてメソッド呼び出しを行いそうですが、Objective-Cでは上記のようにします。&lt;br /&gt;
&lt;br /&gt;
なお、withObjectでパラメータを複数渡したい場合は、複数オブジェクトを格納するNSArrayオブジェクトを渡すようにします。&lt;br /&gt;
また、afterDelay:で秒数を指定すれば、任意の秒数後にメソッド呼び出しが行われます。</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/6550342788491623078/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2010/12/blog-post_10.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/6550342788491623078'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/6550342788491623078'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2010/12/blog-post_10.html' title='変更される可能性のあるクラスのメソッドを呼び出す'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-8469458445532587531</id><published>2010-12-10T17:57:00.001+09:00</published><updated>2010-12-10T17:58:05.228+09:00</updated><title type='text'>NULLとnil</title><content type='html'>NULLとnilはどちらも値としては同じ０のようです。&lt;br /&gt;
&lt;br /&gt;
しかし、NULLはポインタに対して空という意味であり、&lt;br /&gt;
nilはオブジェクトに対して空という意味を表すそうです。&lt;br /&gt;
&lt;br /&gt;
ＣやＣ＋＋言語でBOOL型に０かFALSEを使いましたが、それと似たような感じです。&lt;br /&gt;
現状ではNULLでもnilでもどちらでも良さそうですが、今後問題とならないように、きちんと使い分けをしておいた方が良いかもしれません。&lt;br /&gt;
&lt;br /&gt;
ところで、NSMutableArrayにnilを追加することはできないようですが、NSNullという空の意味を表すオブジェクトが用意されており、これを使えば追加することができるそうです。</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/8469458445532587531/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2010/12/nullnil.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/8469458445532587531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/8469458445532587531'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2010/12/nullnil.html' title='NULLとnil'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7725244335912421956.post-2624063980255300195</id><published>2010-12-08T09:27:00.000+09:00</published><updated>2010-12-08T09:27:37.979+09:00</updated><title type='text'>独自のUIViewを作る</title><content type='html'>独自のUIViewを作るには、描画処理を独自に作成する必要があります。&lt;br /&gt;
&lt;br /&gt;
UIViewでは描画を行う時に「drawRect:(CGRect)rect」メソッドが呼び出されます。&lt;br /&gt;
&lt;br /&gt;
このメソッドをオーバーライドして独自の描画処理を行わせます。&lt;br /&gt;
&lt;br /&gt;
独自のUIViewを作成するのは、割と低レベル（OSに近くなると言う意味）なことですので、Ｃ言語の関数で描画を行う必要があります。また、フォントの扱い等、多少クセがあるようです。&lt;br /&gt;
&lt;br /&gt;
&lt;HR&gt;-(void)drawRect:(CGRect)rect&lt;br /&gt;
{&lt;br /&gt;
 // 描画範囲を取得&lt;br /&gt;
 CGRect parentViewBounds = self.bounds;&lt;br /&gt;
 &lt;br /&gt;
 // ビューのコンテクストを取得&lt;br /&gt;
 CGContextRef ctx = UIGraphicsGetCurrentContext();&lt;br /&gt;
&lt;br /&gt;
 // 塗りつぶし色設定&lt;br /&gt;
 CGContextSetFillColorWithColor(ctx, [UIColor whiteColor].CGColor);&lt;br /&gt;
 &lt;br /&gt;
 // 塗りつぶし色でビューを塗りつぶし&lt;br /&gt;
 CGContextFillRect(ctx, CGRectMake(0, 0, parentViewBounds.size.width, parentViewBounds.size.height));&lt;br /&gt;
 &lt;br /&gt;
 // 描画設定終了&lt;br /&gt;
 CGContextClosePath(ctx);&lt;br /&gt;
 &lt;br /&gt;
 // パスを描画&lt;br /&gt;
 CGContextStrokePath(ctx);&lt;br /&gt;
}&lt;br /&gt;
&lt;HR&gt;UIViewのboundプロパティは、自身のUIViewの描画範囲をCGRect構造体で取得するプロパティです。&lt;br /&gt;
&lt;br /&gt;
UIGraphicsGetCurrentContext()関数は、自身のUIViewインスタンスのコンテキストを取得する関数です。後の描画関数で引数として使用されます。&lt;br /&gt;
&lt;br /&gt;
上記では、色の設定関数（CGContextSetFillColorWithColor）や塗りつぶし関数（CGContextFillRect）を呼び出していますが、実際の描画は最後に呼び出している描画関数（CGContextStrokePath）で行われます。色やパスの設定関数を呼び出した時点ではないことに少し注意が必要です。&lt;br /&gt;
例えば、色を何回変更してパスの設定を行ったとしても、実際の変更が行われるのはCGContextStrokePath等の描画関数を呼び出した時点ですので、途中の色設定は無視されて、最後の色設定のみが反映されることになります。&lt;br /&gt;
&lt;br /&gt;
また、マウス操作などでリアルタイムに描画を変更したい場合などは、「setNeedsDisplayInRect」メソッドを呼び出せば、いつでもdrawRectメソッドがCallbackされます。&lt;br /&gt;
&lt;HR&gt; [self setNeedsDisplayInRect:self.frame];&lt;br /&gt;
&lt;HR&gt;&lt;br /&gt;
&lt;br /&gt;
描画を行う関数は大量にありますが、ほんの一部を抜き出すと、以下のようになります。&lt;br /&gt;
もっと知りたい方は、ドキュメントをCGContextで検索すればたくさん出てきます。&lt;br /&gt;
&lt;br /&gt;
&lt;TABLE border=&quot;1&quot;&gt;&lt;TR&gt;&lt;TD&gt;関数&lt;/TD&gt;&lt;TD&gt;概要&lt;/TD&gt;
&lt;TR&gt;&lt;TD&gt;CGContextAddLines&lt;/TD&gt;&lt;TD&gt;線の描画設定&lt;/TD&gt;
&lt;TR&gt;&lt;TD&gt;CGContextAddPath&lt;/TD&gt;&lt;TD&gt;パスの描画設定&lt;/TD&gt;
&lt;TR&gt;&lt;TD&gt;CGContextSetStrokeColorWithColor&lt;/TD&gt;&lt;TD&gt;線の色設定&lt;/TD&gt;
&lt;TR&gt;&lt;TD&gt;CGContextSetLineWidth&lt;/TD&gt;&lt;TD&gt;線の太さ設定&lt;/TD&gt;
&lt;TR&gt;&lt;TD&gt;CGContextSetFillColor&lt;/TD&gt;&lt;TD&gt;塗りつぶし色設定&lt;/TD&gt;
&lt;TR&gt;&lt;TD&gt;CGContextShowTextAtPoint&lt;/TD&gt;&lt;TD&gt;テキストの設定&lt;/TD&gt;
&lt;TR&gt;&lt;TD&gt;CGContextSelectFont&lt;/TD&gt;&lt;TD&gt;フォントの設定&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TABLE&gt;&lt;br /&gt;
上記表は描画関数のほんの一部です。上記表にはありませんが、イメージを描画したり、カーブ線を描画する関数もあるようです。</content><link rel='replies' type='application/atom+xml' href='http://technical-iphone.blogspot.com/feeds/2624063980255300195/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://technical-iphone.blogspot.com/2010/12/uiview.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/2624063980255300195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7725244335912421956/posts/default/2624063980255300195'/><link rel='alternate' type='text/html' href='http://technical-iphone.blogspot.com/2010/12/uiview.html' title='独自のUIViewを作る'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>