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 6598703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:23:13+00:00 2026-05-25T18:23:13+00:00

My iOS application uses CoreData to store many things, and NSUserDefaults to store other

  • 0

My iOS application uses CoreData to store many things, and NSUserDefaults to store other things that CoreData would be overkill for.

I’m going to simplify this so bear with me (Note: for the sake of this example let’s use credit cards). When my application loads it displays a list of saved credit cards. Now, when each card is added it is assigned a number 1-10 (let’s call it cardNum) that stays with the card for the life of it.

So we add one card and assign it #1. We add another card and assign it #2. Another… #3. We can set a default card that will be highlighted on launch by tapping it. What it does is saves the cardNum as the cDefault to NSUserDefaults to keep track of it (effectively setting card X as the default card).

(crude drawing of a table view)

//cDefault is 2
------------
1 - Card1
------------
2 - Card2 (cDefault)
------------
3 - Card3
------------
4 - Card4
------------

So let’s say we assign cDefault to 2 and then next week we delete that card. On deletion, I need to automatically assign one of the other cards to be a default card.

(crude drawing of table view AFTER card 2 is deleted – note how cDefault is still set…)

//cDefault is still 2
------------
1 - Card1
------------
3 - Card3
------------
4 - Card4
------------

So my question is how, upon deletion, to set another card as cDefault (i.e if it was an array I would probably set the new default to the cDefault value of whatever card is at indexPath.row==0 but I’m not sure if I can do that using CoreData)

Please ask as many questions as you need to. I tried to explain this to the best of my abilities but if I was unclear on anything please ask me.

Thank you so much in advance.
James

  • 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-25T18:23:15+00:00Added an answer on May 25, 2026 at 6:23 pm

    First, I don’t understand why you have to separate certain informations from your managed objects… I would define a BOOL property like “highlighted” in the Card class and handle all your stuff in core data… it sounds more OOP to me 😛
    Second, I didn’t try it before, but you can subscribe to the NSNotificationCenter and listen to NSManagedObjectContextDidSaveNotification, that notification contains an userInfo dictionary with a key named NSDeletedObjectsKey that should contains a set of deleted objects (cards), in your selector you can write the piece of logic to update the objects in the store (that is, set the “highlighted” property to YES for the first card for example)… this approach is cool because can be placed anywhere in your code, anyway the simplest and obvious place to handle the update is where you are deleting the card.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iOS application that uses GPS for Location Services. A user would
I'm developing web-application (and also native iOS app) that uses images from different websites.
All, I'm working on a web application for iOS that uses a fixed position
I am working on an application that uses the Game Center feature from iOS
I am developing an iOS application that comes pre-loaded with CoreData content. I am
I'm developping an iPad application that uses CoreData with iCloud. It works great! I'm
I am writing an application that uses UIImagePickerController to take multiple pictures with the
I have web application that uses JasperReports for PDF report generation. I'd like to
I'm writing an application in PhoneGap that I want to run on iOS, Android,
I have an application that picks up some data (numbers) from the iOS and

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.