saving current date and time in my iPhone application?

前端 未结 2 1282
天命终不由人
天命终不由人 2021-01-23 03:46

In my application i am using In - App purchases to provide a subscription of 1 year….now i need to save the time and date when the user buys the subscription an

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-23 04:44

    You can simply store it in NSUserDefaults:

    [[NSUserDefaults standardUserDefaults] setObject:[NSDate now] forKey:@"purchaseDate"];
    

    Then retrieve it like such:

    NSDate *purchaseDate = [[NSUserDefaults standardUserDefaults] objectForKey:@"purchaseDate"];
    

    And when you're done with it:

    [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"purchaseDate"];
    

提交回复
热议问题