This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DetailViewController.h | |
@property (strong, nonatomic) NSDictionary *item; | |
DetailViewController.m | |
@synthesize item; | |
MasterViewController.m | |
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// アイコンのプレースホルダを設定 | |
cell.imageView.image = [UIImage imageNamed:@"placeholder"]; | |
// アイコンのURLからリクエストを作る | |
NSString *iconURLString = [[[item objectForKey:@"im:image"] objectAtIndex:0] objectForKey:@"label"]; | |
NSURL *iconURL = [NSURL URLWithString:iconURLString]; | |
NSURLRequest *request = [NSURLRequest requestWithURL:iconURL]; | |
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
・https://dl.dropbox.com/u/26298425/3daysiOSApp/placeholder.png | |
の画像をDL | |
・プロジェクトに追加(ファイルをナビゲータエリアにドラッグ) | |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
// セルの初期化などの後に… | |
cell.imageView.image = [UIImage imageNamed:@"placeholder"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// 空の配列を用意 | |
self.items = [NSArray array]; | |
[self getJSON]; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 配列を作る | |
NSArray *iphones = [NSArray arrayWithObjects:@"iPhone3G", @"iPhone3GS", @"iPhone4" nil]; | |
// 配列から要素を取り出す | |
NSString *item2nd = [iphones objectAtIndex:2]; | |
NSLog(item2nd); // ログに iPhone4 | |
// 辞書を作る | |
NSDictionary *macbookair = [NSDictionary dictionaryWithObjectsAndKeys: | |
@"1.7GHz", @"cpu", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)getURL | |
{ | |
// URLクラスを作る | |
NSURL *url = [NSURL URLWithString:@"http://apple.com"]; | |
// リクエストを作る | |
NSURLRequest *request = [NSURLRequest requestWithURL:url]; | |
// 接続してデータを取得 | |
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
さまざまなフィード | |
Amazon ベストセラーランク(RSS) | |
http://www.amazon.co.jp/gp/rss/bestsellers/books/ref=zg_bs_books_rsslink | |
YouTube - ColdPlay公式チャンネル(RSS) | |
http://gdata.youtube.com/feeds/base/users/ColdplayTV/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile | |
Apple Store - ニュース(JSON) | |
http://itunes.apple.com/jp/rss/topfreeapplications/limit=10/json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
// セルのタイトルを取得 | |
NSString *name; | |
if (indexPath.row == 0) { | |
name = @"name01"; | |
} else if (indexPath.row == 1) { | |
name = @"name02"; | |
} else if (indexPath.row == 2) { | |
name = @"name03"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SafariでURLを開く | |
NSURL *urlSafari = [NSURL URLWithString:@"https://twitter.com/"]; | |
[[UIApplication sharedApplication] openURL:urlSafari]; | |
// Mailでメールを送る | |
NSURL *urlMail = [NSURL URLWithString:@"mailto:inouetakayuki@gmail.com"]; | |
[[UIApplication sharedApplication] openURL:urlMail]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ViewController.h に IBOutlet を作成 | |
@property (strong, nonatomic) IBOutlet UIImageView *imageView; | |
// ViewController.m で 画像をセット | |
//(あらかじめ image_name.png をプロジェクトに追加) | |
self.imageView.image = [UIImage imageNamed:@"image_name"]; |
NewerOlder