2012-02-04 8 views
0

私のアプリは、データベースから別のテキストデータを選択するために使用します。また、毎日ローカル通知を表示する機能があります。私は次のコードを使用していますiPhone:ローカルの通知のためにそれぞれの異なるテキストをアラートで表示することは可能ですか?

:今

UILocalNotification *localNotif = [[UILocalNotification alloc] init]; 
if (localNotif == nil) 
    return; 
localNotif.fireDate = [itemDate addTimeInterval:-(minutesBefore*60)]; 
localNotif.timeZone = [NSTimeZone defaultTimeZone]; 

localNotif.alertBody = @"Hey"; // Can I select random message for this notification? 
localNotif.alertAction = NSLocalizedString(@"View Details", nil); 

localNotif.soundName = UILocalNotificationDefaultSoundName; 
localNotif.applicationIconBadgeNumber = 1; 

NSDictionary *infoDict = [NSDictionary dictionaryWithObject:item.eventName forKey:ToDoItemKey]; 
localNotif.userInfo = infoDict; 

[[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; 
[localNotif release]; 

は、それがローカル通知のために別のテキストデータを表示することは可能ですか?どうやって ?

+0

あなたは、表示したい異なるテキストの例を挙げることができます。 – Leena

+0

@Leena:ランダムな言葉:localNotif.alertBody = @ "Hey";それ以外の場合はlocalNotif.alertBody = @ "Hello";そうでなければlocalNotif.alertBody = @ "OH great"; – Devang

+0

文字列の配列を作成し、文字列をランダムに選択してlocalnotification.alertbody – Leena

答えて

0

あなたは文字列の配列を作成することができ、たびにランダムオブジェクトを選択して、それをlocalnotif本体に割り当てます。

+0

@:上記のコードは、あなたのローカル通知を設定するときに一度だけ実行されます。だから1つのメッセージを選び、翌日には同じように表示されます...ランダムにしたいところです。 – Devang

関連する問題