2013-08-08 2 views
2

로컬 알림에 초를 추가 할 수 있는지 알고 싶습니까? 각 지역 알림을 30 초 후에 예약하기 위해 루프를 만들려고합니다. 그래서, 아래의 루프에서, 나는 30 초 후에 서로를 "지연시키는"것을 계속 유지할 수 있습니까? 나는 그 질문이 의미가 있는지 알지 못하지만, 그것이 내 문제를 기술 할 수있는 최선의 방법이다. 30 초 간격으로 생각하고 각 알림을 수동으로 예약하십시오.self.timepicker 날짜에 초 추가 (로컬 알림 목적으로)

for (notifs = 1, notifs <= 64, notifs ++) 
{ 
    UILocalNotification* localNotification = [[UILocalNotification alloc] init]; 

localNotification.fireDate = [self.timePicker date]; 

// [self.timePicker date] + 30000처럼 쓸 수 있습니까?

localNotification.soundName = @"notifsound.caf"; 
localNotification.alertBody = @"Wake Up!!!"; 
localNotification.timeZone = [NSTimeZone defaultTimeZone];   
} 

감사합니다.

답변

2

당신은있는 NSDate의 dateByAddingTimeInterval:를 사용하고 단지 30

for (notifs = 1; notifs <= 64; notifs ++) 
{ 
    UILocalNotification* localNotification = [[UILocalNotification alloc] init]; 

    localNotification.fireDate = [[self.timePicker date] dateByAddingTimeInterval:notifs * 30.0]; 

    localNotification.soundName = @"notifsound.caf"; 
    localNotification.alertBody = @"Wake Up!!!"; 
    localNotification.timeZone = [NSTimeZone defaultTimeZone]; 

    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 
} 
+0

+1 정확한 답변을 곱한 현재 반복 번호를 전달할 수 있습니다. – satheeshwaran

+0

@satheeshwaran 그것을 듣기 좋게! 내 게시물이 문제를 해결하면 내 게시물 옆에있는 "체크 표시"를 클릭하여 올바른 것으로 표시하는 것을 잊지 마십시오! :) –

+0

빠른 답장을 보내 주셔서 감사합니다. 내가 iOS에 익숙하지 않아서, 나는이 물건에 익숙하지 않은 조금 아직도 조금이다. 나는 단지 명확히하고 싶다 : 나는 다른 것을 선언 할 필요가 있는가? 아니면 시간 픽커가 유일한거야? – tantantheman