2014年3月22日土曜日

【Objective-C】Viewに追加されたUITextFiledのタグを指定して値を取得する方法

親画面に複数のテキストフィールドがあり、入力を子画面のポップアップでさせた場合に、どのテキストフィールドに入力値を反映させるかの判定に使用出来ます。このやり方を知る前はswitch case tagで分岐して、代入先を静的に設定していました。

□ 前提
テキストフィールドにtagを設定しておく。
テキストフィールドの編集時にlastTagに該当テキストフィールドのtagを設定しておく。

□ サンプルソース
子画面の入力後のdelegateメソッド(updateData)でViewにtag指定してUITextFieldを取得します


- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    lastTag = textField.tag;
}

- (void)updateData :(NSString *) dataValue{
    // viewからtagを検索して
    UITextField* textField = (UITextField*) [self.view viewWithTag:lastTag];
    textField.text = dataValue;

}


2014年3月21日金曜日

【Objective-C】日付(年月日)、時間(時分秒)を求める


- (void) test
{
    NSDate *date         = [NSDate date];
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSDateComponents *comps;
    
    // 年月日
    comps = [calendar components:(NSYearCalendarUnit
                                  | NSMonthCalendarUnit
                                  | NSDayCalendarUnit)
                        fromDate:date];
    NSInteger year  = [comps year];
    NSInteger month = [comps month];
    NSInteger day   = [comps day];
    
    // 時分秒
    comps = [calendar components:(NSHourCalendarUnit
                                  | NSMinuteCalendarUnit
                                  | NSSecondCalendarUnit)
                        fromDate:date];
    NSInteger hour   = [comps hour];
    NSInteger minute = [comps minute];
    NSInteger second = [comps second];
    
    NSString *logs;
    //%03d
    logs = [NSString stringWithFormat:@"%d%02d%02d%02d%02d%02d",year,month,day,hour,minute,second];
    NSLog(@"%@",logs);

}

【App Store】SpaceBoxWarをリリースしました

シンプルなゲームです。スコアを競います。

https://itunes.apple.com/us/app/spaceboxwar/id838230985?l=ja&ls=1&mt=8

【Objective-C】Viewを閉じるソースコード

iOs6以降のview(画面)の閉じ方。

- (IBAction)btnBarBack:(id)sender {
    //警告あり
    //[self dismissModalViewControllerAnimated:YES];
    
    //警告なし
    [self dismissViewControllerAnimated:YES completion:nil];

}


【Objective-C】Dictionaryからkeyとvalを求めて配列に設定する方法

サンプルソースの説明
self.trMasterData.dictMstTrBuiにはあらかじめdictionaryのkey,valが登録されているものとします。dictionaryのallKeysメソッドでkeyの一覧、allValuesメソッドでvalueの一覧をそれぞれ取得し、可変長の配列にコピーしています。その際に(NSMutableArray *)と頭につけてキャストしています。

/* 定義 */
@property (nonatomic) NSMutableArray *arrAllKeysTrHdAll;
@property (nonatomic) NSMutableArray *arrAllValsTrHdAll;

/* サンプルメソッド*/
- (void) arrDataCreate{
    //初期化
    self.arrAllKeysTrHdAll = [[NSMutableArray alloc] init];
    self.arrAllValsTrHdAll = [[NSMutableArray alloc] init];
    
    //key ,val配列生成
    NSArray *arrAllKeys   = [self.trMasterData.dictMstTrBui allKeys];
    NSArray *arrAllValues = [self.trMasterData.dictMstTrBui allValues];
    
    //キャストして登録
    self.arrAllKeysTrHdAll = (NSMutableArray *)[NSArray arrayWithArray:arrAllKeys];
    self.arrAllKeysTrHdAll = (NSMutableArray *)[NSArray arrayWithArray:arrAllValues];

}



【Apple】iTunes connect Metadata Rejectedされた場合はアプリの際アップロードは不要

metadata rejected された原因は「アプリの説明文が不十分」、「スクリーンショットからゲームイメージがつかない」ことが原因でした。説明を追加、スクリーンショットを追加して再審査したところ、数時間でin Reviewのステータスに変わりました。

バイナリーデータのアップロードは不要で、優先的に審査してくれるようです。

【Apple】iTunes connectでProcessing for App Store から Ready for Saleにならない場合

Processing for App Store.からReady for Saleというステータスに変更されるまで、通常10分くらいだそうですが、稀にバグで数時間経っても変更されません。

解決方法は該当アプリのメタデータを編集して更新すれば、それがトリガーとなりステータスが即時にReady for Saleへ変わります。これで無駄に数日待ったという話も聞くので記録しておきます。