{"action":"opened","issue":{"url":"https://api.github.com/repos/podverse/podverse/issues/52","labels_url":"https://api.github.com/repos/podverse/podverse/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/podverse/podverse/issues/52/comments","events_url":"https://api.github.com/repos/podverse/podverse/issues/52/events","html_url":"https://github.com/podverse/podverse/issues/52","id":119247203,"number":52,"title":"PVFeedParser - Mutating array error happens whenever app enters the foreground","user":{"login":"mitchdowney","id":2262919,"avatar_url":"https://avatars.githubusercontent.com/u/2262919?v=3","gravatar_id":"","url":"https://api.github.com/users/mitchdowney","html_url":"https://github.com/mitchdowney","followers_url":"https://api.github.com/users/mitchdowney/followers","following_url":"https://api.github.com/users/mitchdowney/following{/other_user}","gists_url":"https://api.github.com/users/mitchdowney/gists{/gist_id}","starred_url":"https://api.github.com/users/mitchdowney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitchdowney/subscriptions","organizations_url":"https://api.github.com/users/mitchdowney/orgs","repos_url":"https://api.github.com/users/mitchdowney/repos","events_url":"https://api.github.com/users/mitchdowney/events{/privacy}","received_events_url":"https://api.github.com/users/mitchdowney/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/podverse/podverse/labels/priority","name":"priority","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-27T21:20:09Z","updated_at":"2015-11-27T21:20:09Z","closed_at":null,"body":"According to my tests this issue goes away when I comment out lines 109 - 118 in the PVFeedParser:\r\n\r\n```\r\nfor var existingEpisode in downloadedEpisodes {\r\n    if newEpisode.mediaURL == existingEpisode.mediaURL {\r\n        existingEpisode = newEpisode\r\n        episodeAlreadySaved = true\r\n        //Remove the created entity from core data if it already exists\r\n        CoreDataHelper.removeManagedObjectFromClass(\"Episode\", managedObjectContext: Constants.moc, object: newEpisode)\r\n        break\r\n    }\r\n}\r\n```\r\n\r\nI'm not sure why this block is causing the issue so I won't push an attempted fix for it.\r\n\r\nBut I'm thinking the .removeManagedObjectFromClass is at the root of the issue. When removeManagedObjectFromClass removes the object newEpisode, well existingEpisode and newEpisode are the exact same thing, so maybe there are two instances of the same episode floating around in the MOC, and this results in the wrong managed object getting deleted?"}}