2012-02-04 2 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"; else localNotif.alertBody = @ "Hello"; else localNotif.alertBody = @ "OH great"; – Devang

+0

문자열의 배열을 만든 다음 무작위로 문자열을 선택하고 localnotification.alertbody에 할당합니다. – Leena

답변

0

문자열 배열을 만들 때마다 임의의 개체를 선택하여 localnotif 본문에 지정할 수 있습니다.

+0

@ : 위의 코드는 현지 알림을 설정할 때 한 번만 실행됩니다. 그래서 그것은 하나의 메시지를 선택할 것이고 다음날 같은 메시지를 표시 할 것입니다. – Devang

관련 문제