Reputation: 394
I'm just starting Swift, have some Objective-C background... Anyways, why is it that when I do:
I get an error, but when I put it in a func like:
There isn't an error?
Also, can someone please correct my terms? is appDel a reference or a variable? Thanks in advanced - please edit or tell me what's wrong with my question :)
Upvotes: 1
Views: 157
Reputation: 6377
You can't access self
when setting the default value.
Mark it with lazy
attribute can do the trick:
lazy var context: NSManagedObjectContext = self.appDel.managedObjectContext
Upvotes: 2