Weitere ähnliche Inhalte
Ähnlich wie Ll xcode (20)
Mehr von Net Kanayan (20)
Ll xcode
- 3. Xcode とは?
ソフトウェアを開発するための
アップルの統合開発環境
例:
IPhone IPad のアプリケーション
- 10. 1.始めるキッカケ
ブルーベリーの栽培記録を
その場で残せるアプリが欲しかった
(土壌PH や 農薬 や 肥料など)
↓↓↓↓↓
作ればいいじゃない!?
- 13. アプリの構成
HTTP
Web API
農作物や日記の入力
データの保存
描画
呼び出し
- 17. 苦戦した箇所
javascript(Jquery) の場合
$.ajax({
type: "POST",
url: "http://example.com",
data: "xxx=yyy",
success: function(msg){
alert( "成功: " + msg );
}
});
- 18. 苦戦した箇所
objective-c の場合
みなさん使ってるライブラリあるのかな∼?
っとググってみる....
↓↓↓↓↓
自作ライブラリ配布してる人はいたけど...
多くがコツコツ書いてる...
- 19. 苦戦した箇所
objective-c の場合
NSURL *nsurl = [NSURL URLWithString:@”http://example.com”];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:
nsurl];
[request setHTTPMethod: @"POST"];
[request setValue:@"application/x-www-form-urlencoded"
forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d", [sendData length]]
forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: sendData];
NSError *error;
NSURLResponse *response;
NSData *buffer = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response error:&error];
- 21. 2. HTML との違い
例: Table 表示
HTML の場合
<table width=100% border=1 width=100%>
<tr>
<td>セル1</td>
</tr>
<tr>
<td>セル2</td>
</tr>
<tr>
<td>セル3</td>
</tr>
</table>
- 23. //セルの数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// table_list の中身は配列
return [table_list count];
}
// セルの中身の設定
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"product_items";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSInteger row = [indexPath row];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
cell.textLabel.font = [UIFont boldSystemFontOfSize:18];
NSDictionary *table_row = [table_list objectAtIndex:row];
cell.textLabel.text = [table_row objectForKey:@"subject"];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
return cell;
}
//セルの高さ
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 42;
}
- 25. 苦戦しなかった箇所
JSON ( javascript )
var json_string = { status : ok } ;
var json_obj = JSON.parse(json_string);
console.log( json_obj.status ); // -> ok
- 26. 苦戦しなかった箇所
JSON
Objective-c
// json_string にjson文字列 json_string = ‘{”status”:”ok”}’
NSData *json_data = [json_string dataUsingEncoding:NSUTF8StringEncoding];
NSMutableArray *ret = [NSJSONSerialization JSONObjectWithData:json_data
options:NSJSONReadingAllowFragments error:nil];
[ret objectForKey:@"status"]; // -> ok
Hinweis der Redaktion
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n