Skip to content

Commit

Permalink
Keep semaphore reference in local
Browse files Browse the repository at this point in the history
In case self is deinited
  • Loading branch information
SteveKChiu committed Oct 28, 2015
1 parent cac7f26 commit c5e6649
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CoreDataMonk.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "CoreDataMonk"
s.version = "0.9.6"
s.version = "0.9.7"

s.summary = "A flexible and easy-to-use CoreData library for Swift"
s.description = <<-DESC
Expand Down
9 changes: 4 additions & 5 deletions CoreDataMonk/CollectionViewDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ private class CollectionViewDataBridge<EntityType: NSManagedObject>
return
}

dispatch_semaphore_wait(self.semaphore, dispatch_time(DISPATCH_TIME_NOW, Int64(NSEC_PER_SEC)))
let semaphore = self.semaphore
dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, Int64(NSEC_PER_SEC)))
self.collectionView?.performBatchUpdates({
[weak self] in
if let actions = self?.pendingActions where !actions.isEmpty {
Expand All @@ -167,10 +168,8 @@ private class CollectionViewDataBridge<EntityType: NSManagedObject>
}
}, completion: {
[weak self] _ in
if let this = self {
this.provider?.onDataChanged?()
dispatch_semaphore_signal(this.semaphore)
}
self?.provider?.onDataChanged?()
dispatch_semaphore_signal(semaphore)
})
}
}
Expand Down

0 comments on commit c5e6649

Please sign in to comment.