Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7178703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:58:25+00:00 2026-05-28T16:58:25+00:00

I have an application that displays videos. The code below gets a list of

  • 0

I have an application that displays videos. The code below gets a list of videos (using core data), filters it to only the videos that have been viewed before, and then finds the next video and adds it to the list of videos.

Basically instead of showing every video I am just showing the previously viewed videos + the one you should view next.

videos = [[loader loadVideos] mutableCopy];

// Get only the viewed videos
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(viewed == YES)"];

NSMutableArray *viewedVideos = [[videos filteredArrayUsingPredicate:predicate] mutableCopy];

Video *lastWatchedVideo = [viewedVideos lastObject];
// The next video will be equal to the video order of the previous video (starting at 1 vs 0)
Video *todaysVideo = [videos objectAtIndex:[lastWatchedVideo.videoOrder intValue]];

[viewedVideos addObject:todaysVideo]; 

Everything is working as expected in the UI, except any changes to the todaysVideo object (e.g. marking it as viewed) are not being saved back to the database. Is this because I have moved it to another array?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:58:26+00:00Added an answer on May 28, 2026 at 4:58 pm

    Yes, that is why your changes are not being saved into the core data. You are creating a local copy of the core data and modifying it. This will not be reflected in the core data. Change your code to this and see if it works

    videos = [loader loadVideos];//You get the videos from core data
    // Get only the viewed videos
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(viewed == YES)"];
    NSMutableArray *viewedVideos = [videos filteredArrayUsingPredicate:predicate];
    Video *lastWatchedVideo = [viewedVideos lastObject];
    // The next video will be equal to the video order of the previous video (starting at 1 vs 0)
    Video *todaysVideo = [videos objectAtIndex:[lastWatchedVideo.videoOrder intValue]];
    todaysVideo.viewed=YES;
    //Now that you have modified it save the context
    NSError *error=nil;
    [context save:&error];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that displays the data from 3 xml files (auto generated
I have a PHP application that displays a list of options to a user.
I have a mature MFC C++ application that displays on screen and prints using
In my application I have a DataGridView control that displays data for the selected
I have one application in which list of videos that are coming through xml
I have an application that displays a ListView using a CursorAdapter that I have
I have an application that displays an image inside of a Windows Forms PictureBox
I have a portlet. Inside of this portlet I have Flex application that displays
I have an .Net Froms application that displays web pages through a WebBrowser control.
We have an application that has to be flexible in how it displays it's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.