MessageListCell *Cell;
Cell = (MessageListCell *)[self.tblMain cellForRowAtIndexPath: delegateJSON.indexPath];

の様な使い方でセルを作成して後から表示させるようなときに、テーブルの表示から呼び出した処理(ここではdelegateJSONでJSONの取得)を完全に非同期にしないと、セルはさくせいされない。理由はよくわからないですが、3時間ほどはまったので、メモ
2013年09月22日

データのソート

今日は少しデータのソートで悩んでしまったので、メモです。
自分のソースを貼付けてるだけなので、他の人には参考にならないと思いますが。すいません。


- (IBAction)setSendList:(id)sender{
strSelectedIDs = nil;
NSArray *sortedArray = [[NSArray alloc]initWithArray:[friendsDatas sortedArrayUsingFunction:compareInfo context:NULL]];
for (int i=0; i<[sortedArray count]; i++) {
DataFriends *bookData = (DataFriends *)[sortedArray objectAtIndex:i];
if (bookData.intDoSend==1) {
if (strSelectedIDs != nil) {
[strSelectedIDs appendString:@","];
}
[strSelectedIDs appendString:[NSString stringWithFormat:@"%d",bookData.primaryKey]];
}
}
[self.delegate SelectFriendViewControllerDidOK:self];
}

NSInteger compareInfo(id aInfo1, id aInfo2, void *context)
{
int dpercent1 = ((DataFriends*) aInfo1).primaryKey;
int dpercent2 = ((DataFriends*) aInfo2).primaryKey;

if (dpercent1 < dpercent2)
return NSOrderedDescending;
else if (dpercent1 > dpercent2)
return NSOrderedAscending;
else
return NSOrderedSame;
}
よく使うのですが、結構忘れるのでメモです。


NSCalendar *cal=[NSCalendar currentCalendar];

NSUInteger flags = NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit;
NSDate * tmpDate =[NSDate dateWithTimeInterval:-[[NSTimeZone systemTimeZone] secondsFromGMT] sinceDate:[NSDate date]]; //->これを入れとかないと、グリニッジ標準時刻になってしまう

NSDateComponents *cmp = [cal components:flags fromDate:tmpDate];
NSDate* date_converted;

// NSDateFormatter を用意します。
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];

// 変換用の書式を設定します。
[formatter setDateFormat:@"YYYY-MM-dd"];
[formatter setDateFormat:@"yyyy-MM-dd"]; //YYYYだとどうしてか、去年になってしまいます。

// NSString を NSDate に変換します。
date_converted = [formatter dateFromString:[NSString stringWithFormat:@"%04d-%02d-%02d",[cmp year],[cmp month],[cmp day]]];

// 使い終わった NSDateFormatter を解放します。
[formatter release];
iPhone5が登場する前に作ったアプリをこれに対応さそうとして、xibファイルを色々触っても、思ったようにならないとき、

デリゲートファイルでのdidFinishLaunchingWithOptionsのところで
 [_window addSubview:_viewController.view];
となっている(古いパターン)場合があります。

このときは
self.window.rootViewController = self.viewController;
と変更してやると、うまく行きました。

他の原因もありそうですが、これで解決したのでメモしておきます。
アップルのアプリの審査はどんどん、厳しくなってるような気がします。
それか、私が時々変なアプリを提出するから目を付けられてるかもしれませんww
ただ、アプリ内課金に関してはほんとに厳しくなってるようです。
今回はリストア処理を忘れて、英語で理由を返されて、意味不明な状態になったので、次回以降のためにメモっときます。

We found that while your app offers In-App Purchase(s) that can be restored, it does not include the required “Restore” feature to allow users to restore the previously purchased In-App Purchase(s), as specified in Restoring Transactions section of the In-App Purchase Programming Guide:
“…if your application supports product types that must be restorable, you must include an interface that allows users to restore these purchases. This interface allows a user to add the product to other devices or, if the original device was wiped, to restore the transaction on the original device.”
To restore previously purchased In-App Purchase products, it would be appropriate to provide a “Restore” button and initiate the restore process when the “Restore” button is tapped by the user.
For more information about restoring transactions and verifying store receipt, please refer to the In-App Purchase Programming Guide.

という文章が帰って来たのですが、一度購入したユーザーが再度購入するときのための処理を実装しなさいということらしいです。

http://maccle.com/objective-c-cocoa/rejected-in-order-to-restore-in-app-purchase/
や、参考書を参考にして、うまくいきましたが、

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

の前に
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
を行っていなかったので、処理結果が帰ってこずに、結構ハマってしまいましたので、次回から注意です。

ちなみに、このことを実装したら審査通りました。ありがとうございます!!

2013年04月20日

コンパイル時のエラー

今回は、zbarというバーコードを読み取るsdkを実装したときのコンパイルエラーについてです。
そのままでも、iPhone5以外は動作したのですが、iPhone5でだけビルドエラーになりました。

file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/imae/Desktop/ZBarSDK/libzbar.a for architecture armv7s

というような、エラーメッセージです。

このような場合はBuildSettingでArchiteturesをStandard(armv7,armv7s)からarmv7に変更したらビルドできました。

このビルドエラーは厄介で色んなパターンがあるのですが、今回解決した方法をメモしておきます。
2013年04月19日

手書き文字認識

今日は新しいネタを見つけましたので、そのことをメモしときます。
zinniaっていうのを使うと、アプリに手書き認識を手軽に実装できそう。
http://d.hatena.ne.jp/kaz_29/20111214/1323841470
オーダリングの端末として使うにはいいかもです。
プロフィール
けん
カテゴリ
VB関係 (4)
iOS関係 (7)
SQL関係 (1)
< 2025年05月 >
S M T W T F S
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
QRコード
QRCODE
※カテゴリー別のRSSです
アクセスカウンタ
読者登録
メールアドレスを入力して登録する事で、このブログの新着エントリーをメールでお届けいたします。解除は→こちら
現在の読者数 0人
人気の楽園ブログ
楽園ブログ