2012-04-24 8 views
3

私はUILocalNotificationを作成していますが、これに対して複数のuserInfoを設定する必要があります。どうすればいいですか?複数のuserInfoをローカル通知に格納

// Create a new notification 

    UIApplication* app = [UIApplication sharedApplication]; 

    UILocalNotification *alarm = [[UILocalNotification alloc] init]; 

    alarm.fireDate = date;   
    alarm.timeZone = [NSTimeZone localTimeZone]; 
    alarm.alertBody = msg;   
    alarm.alertAction = @"View";    
    alarm.repeatInterval = NSYearCalendarUnit; 
    [email protected]"happyBirthday.wav"; 
    alarm.applicationIconBadgeNumber = 1;  

    NSDictionary *userDict = [NSDictionary dictionaryWithObject:detailperson forKey:@"msg"]; 
    NSDictionary *userDictName = [NSDictionary dictionaryWithObject:detailperson2 forKey:@"name"]; 

    alarm.userInfo = userDict; 
    alarm.userInfo = userDictName; 

答えて

5

あなたはとても長いキーがすべて異なっているとして、辞書に複数のオブジェクトを持つことができます。

NSDictionary *userDict = [NSDictionary dictionaryWithObjectsAndKeys:detailperson, @"msg", detailperson2, @"name", nil]; 

alarm.userInfo = userDict; 
1

あなたはコンバイン2つの辞書を単一の辞書と結合し、ユーザー情報に設定ディクショナリそれを使用する必要があります。

 NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:dic1,@"first",dic2,@"second", nil]; 

     alarm.userInfo=dic 
関連する問題