0

I know it's not recommended to save NSMutableArray to Core Data but I need to access the array on another view controller (using one of the segue methods (such as passing a variable to another view controller) won't do the job).

So unless there's another way that I'm not aware of, how can I save the array to core data?

I'm using Swift.

nick9999
  • 601
  • 1
  • 8
  • 22
  • Welcome to Stack Overflow. If you provide a code example of what you have tried, someone may be able to help you better. Why can't you pass it to the view controller directly? You shouldn't be saving temporary run-time data to Core Data. – Ian MacDonald Feb 14 '15 at 18:40
  • I retrieve the array from parse. If I can't save it somehow and the user shuts down the app, more bandwidth with have to be used to retrieve on every startup. That's why. :) – nick9999 Feb 14 '15 at 18:42
  • I haven't really tried anything because I honestly don't know where to start (don't get me wrong....I know how to use core data for string/int/date, etc) – nick9999 Feb 14 '15 at 18:43
  • Why precisely do you say that you can't pass the array variable to another view controller? You're asking for alternatives, but haven't shared with us what is unique about your situation that makes the typical approach impossible here. How can we possibly answer the question without that information? Core Data is not the right technology simply to pass an array from one view controller to another. – Rob Feb 14 '15 at 19:21

2 Answers2

1

I think your question is not how to save NSMutableArray to Core Data, instead, your question seems like is How to access data on another viewController?

  1. First, I think you can get some knowledge about Delegate.

  2. Second,Here is a Q&A I can share with you which I think may help you to figure out your confused.Passing Data between View Controllers

Community
  • 1
  • 1
alex.xiao
  • 11
  • 1
0
  1. Saving NSArray to Core Data is possible via Transformable-type attributes.
  2. Saving NSMutableArray is not possible. Only immutable ones.

if you want to save a mutable array to core data, use copy method. It will return immutable copy of your mutable object.

kas-kad
  • 3,736
  • 1
  • 26
  • 45