I pass a object from another viewcontroller and try to add a new record on coredata,
object is not nil , but I got the error message below, why? What is that mean "in different contexts"?
'NSInvalidArgumentException', reason: 'Illegal attempt to establish a relationship 'schedule' between objects in different contexts
"in different contexts" means that the two managed objects have been created in different NSManagedObjectContext instances.
If you created a managed object context in the new view controller, you need to get a new NSManagedObject instance for the object:
let objectID = managedObject.objectID
let copy = context2.objectWithID(objectID)
See:
developer.apple.com/library/etc/redirect/xcode/ios/1151/documentation/Cocoa/Conceptual/CoreData/FrequentlyAskedQuestions.html
"How do I copy a managed object from one context to another?"