Reputation: 1974
If I define my array as:
var myList: Array <AnyObject> = []
and then use the viewDidLoad override function to populate this array like this:
override func viewDidAppear(animated: Bool) {
let appDel:AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
let context:NSManagedObjectContext = appDel.managedObjectContext!
let freq = NSFetchRequest(entityName: "List")
myList = context.executeFetchRequest(freq, error: nil)!
tableView.reloadData()
}
and my "List" only contains usernames as strings. What exactly is being stored in "myList"? Is it just as simple as an array of strings with the usernames?
Any thoughts and explanations would be highly appreciated.
Upvotes: 1
Views: 245
Reputation: 5453
executeFetchRequest
returns an array of managed objects from the CoreData data store. There are basically two ways to handle them.
The first is to use them as-is. They will all be instances of NSManagedObject
, and you can use methods like valueForKey:
to get their values.
The second way is to define your own subclass of NSManagedObject
, in your case probably named List
, and then define properties on that object allowing you to access the values directly.
Core Data as a whole is both insanely powerful and insanely complex. I strongly recommend you work through a tutorial, either Apple's or otherwise, to get a hang of it. (Note that some of Apple's docs recommend starting with something called Core Data Starting Point. Helpfully, Apple has retired that document, but hasn't yet removed the references to it from other documents.)
Upvotes: 1
Reputation: 22701
Your myList
would contain subclasses of NSManagedObject
or List
instances if you have defined that class. Each object would have attributes that you have defined for that core data object.
The indexPath
is a class that is used to represent the row
and section
of the UITableView
. This is also used to identify the item
and section
of a UICollectionView
.
Upvotes: 1