mercredi 27 janvier 2016

Objective-C Notify When a New Record has been Added to the Database(sqlite) and Update the TableViewController

I'm parsing a data that I received from a remote notification and then immediately save it on my database within the AppDelegate. But when I received a new remote notification while the app is running, the UITableView doesn't get updated with the new data.

I followed this tutorial on how to use sqlite. But when it comes on notifying when a new element has been added to the database it doesn't work on me since my case is AppDelegate and ViewController and the tutorial's case is ViewController and ViewController

This is how the tutorial does it after implementing the protocol

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    EditInfoViewController *editInfoViewController = [segue destinationViewController];
    editInfoViewController.delegate = self;
}

In my case it will be

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    AppDelegate *appDelegate = [segue destinationViewController];
    appDelegate.delegate = self;
}

and I will get this error:

Cannot initialize a variable of type 'AppDelegate* __strong' with an rvalue of type' __kindofUIViewCOntroller*'

What alternate can I use for prepareForSegue?

I'm kind of lost here so I will appreciate any help that I can get.

Aucun commentaire:

Enregistrer un commentaire