[objective-c]UIButtonのラベルを複数行にする

UIButtonのラベルを複数行にする

testbutton.layer.borderWidth=1.0;
[testbutton setTitle:@"あいうえお\nかきくけこ" forState:UIControlStateNormal];
UILabel*innerLabel= testbutton.titleLabel;
innerLabel.numberOfLines=0;
innerLabel.frame=CGRectMake(0, 0, testbutton.frame.size.width, testbutton.frame.size.height);

[objective-c]EGODatabase #6

EGODatabase #6
下記の処理を実行しただけではuser.dbは作成されていない。
ファイルはexecuteQueryを実行すると作成される。

NSString*filepath=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/user.db"];
EGODatabase* database = [EGODatabase databaseWithPath:filepath];

[objective-c]jsonを読み込む

jsonを読み込む

NSString*url = @"/php/45/";
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
NSData *json_raw_data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *json = [[NSString alloc] initWithData:json_raw_data encoding:NSUTF8StringEncoding];
NSData *json_data = [json dataUsingEncoding:NSUnicodeStringEncoding];
NSError *error=nil;
id data = [NSJSONSerialization JSONObjectWithData:json_data options:NSJSONReadingAllowFragments error:&error];
if (error) {
    NSLog(@"---error code:%d %@",error.code,[error localizedDescription]);
}else{
    if( [data isKindOfClass:[NSArray class]] ){
        NSLog(@"---array");
        
    }else if( [data isKindOfClass:[NSDictionary class]] ){
        NSLog(@"---dic");
    }
}

[objective-c]よく忘れるローカライズ

よく忘れるローカライズ

projectのinfoを開く
s00

なんか出るのでjapaneseを選択
s01

InfoPlist.stringsだけ選択してFinish
s02

New Fileでファイルを追加する
s03

ResourceのStrings Fileを選択
s04

ファイル名はLocalizable.strings
s05

Localizable.stringsを選択して右側のLocalizeをクリック
s06

なんか出るのでとりあえずEnglishを選んでLocalizeクリック
s07

右側のEnglish,Japaneseをチェックする。Baseは外しても問題ない¨多分
s08

InfoPlist.stringsにはアイコンの下に表示するアプリ名を設定
半角で11文字,全角で6文字以内

CFBundleName = "jeff";
CFBundleDisplayName= "jeff";

Localizable.stringsには言語毎の文字列を設定

cancel="Cancel";
ok="OK";
back="Back";

使うときはこう

NSLocalizedString(@"back", nil);