Running the following code aborts in the return line
Type is not Workout 
Could not cast value of type 
'NSManagedObject_Workout_' (0x7fcca20620f0) to 
'AppName.Workout' (0x100ea5f40)). 
The part inside if let... is never executed.
func createWorkoutWithName (name: String) -> Workout? {
    let entityName = NSStringFromClass(Workout.classForCoder())
    let newEntity = NSEntityDescription.insertNewObjectForEntityForName(entityName, inManagedObjectContext: managedObjectContext)
    if let newEntity = newEntity as? Workout {
        newEntity.name = name
    }
    NSLog("createWorkoutWithName: Type is not Workout")
    return (newEntity as! Workout)
}
I had this problem in the past and I solved it in XCode 6.x by going in the entity inspector and setting Class = AppName.Workout
One of several answers that suggests this solution is How come I can cast to NSManagedObject but not to my entity's type?
XCode 7 adds a new twist to this problem: When I set
Class = AppName.Workout
in the entity inspector, XCode 7 changes the class name automagically to
Class = AppNameWorkout
by removing the dot between AppName and ClassName.
So how can I do this in XCode 7 when I can't set a dot between AppName and ClassName?