how can I write NSLocalNotification object to sqlite database

555 Views Asked by At

I am using local notification ,i need to update/delete the notification for that I think I have to write object to database so that I can retrieve later then I can delete from the operating system ,so my issue is that how to write object to database any help plz?

3

There are 3 best solutions below

0
On BEST ANSWER

Have a look at using Core Data.

1
On

DataType of your notification column is BLOB and following code is used to enter data in DB.

UILocalNotification *localNotification;    
[NSKeyedArchiver archivedDataWithRootObject:localNotification]

And to get it back as notification object use following code.

NSData *data = database column value of notification object;

   UILocalNotification *notif = (UILocalNotification*)[NSKeyedUnarchiver unarchiveObjectWithData:data];
0
On

You don't really need to fetch them from a db there is a method to get an array of all of your notifications