IOS CoreData Cascade Delete

Source: Internet
Author: User

The application scenario is as follows, each user can set multiple reminders, when deleting a user, you should delete the relevant reminders, and delete a reminder, you should delete the reminder from the user information.

Then profile should create a relationship.

And reminder should be built like relationship.

When adding reminder to a profile, to set the relationship of 2 objects, see the following example code:

                if(Profile! =Nil) {Reminder.profileid=Current_profile.pid; Reminder.contents= @[@"First Contents"]; Reminder.type=[NSNumber NumberWithInt:self.type]; Reminder.repeattype=[NSNumber numberwithint:erepeattypeweekly]; Reminder.profile=Profile ; Nsmutableset*reminderset =[[Nsmutableset alloc] initWithSet:profile.reminder];            [ReminderSet Addobject:reminder]; Profile.reminder=ReminderSet; }

After the above process, when you delete a profile from the database, the associated reminder will be automatically deleted.

It is important to note that when you set an object's relationship delete rule, it refers to what to do with this relationship property when you delete this object.

IOS CoreData Cascade Delete

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.