Skip to content

Commit 64ed18c

Browse files
committed
2.1.3 — Generated Files
1 parent 3f2c54d commit 64ed18c

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

Categories/Foundation/NSNotificationCenter+Promise.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import Foundation.NSNotification
1515

1616
*/
1717
extension NSNotificationCenter {
18-
class func once(name: String) -> Promise<[NSObject: AnyObject]> {
18+
public class func once(name: String) -> Promise<[NSObject: AnyObject]> {
1919
return once(name).then(on: zalgo) { (note: NSNotification) -> [NSObject: AnyObject] in
2020
return note.userInfo ?? [:]
2121
}
2222
}
2323

24-
class func once(name: String) -> Promise<NSNotification> {
24+
public class func once(name: String) -> Promise<NSNotification> {
2525
return Promise { fulfill, _ in
2626
var id: AnyObject?
2727
id = NSNotificationCenter.defaultCenter().addObserverForName(name, object: nil, queue: PMKOperationQueue){ note in

PromiseKit.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#if defined(PMKEZBake) && defined(SWIFT_CLASS)
3434
// https://github.com/PromiseKit/EZiOS7/issues/2
35-
#define PMKPromise AnyPromise
35+
#define AnyPromise PMKPromise
3636
#else
3737
#if !defined(SWIFT_PASTE)
3838
# define SWIFT_PASTE_HELPER(x, y) x##y

PromiseKit.swift

+9-3
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,14 @@ private class Consumable: NSObject {
358358
private var handle: UInt8 = 0
359359

360360
func consume(error: NSError) {
361-
let pmke = objc_getAssociatedObject(error, &handle) as! Consumable
362-
pmke.consumed = true
361+
// The association could be nil if the objc_setAssociatedObject
362+
// has taken a *really* long time. Or perhaps the user has
363+
// overused `zalgo`. Thus we ignore it. This is an unlikely edge
364+
// case and the unhandled-error feature is not mission-critical.
365+
366+
if let pmke = objc_getAssociatedObject(error, &handle) as? Consumable {
367+
pmke.consumed = true
368+
}
363369
}
364370

365371
extension AnyPromise {
@@ -376,7 +382,7 @@ func unconsume(error: NSError) {
376382
} else {
377383
// this is how we know when the error is deallocated
378384
// because we will be deallocated at the same time
379-
objc_setAssociatedObject(error, &handle, Consumable(parent: error), objc_AssociationPolicy(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
385+
objc_setAssociatedObject(error, &handle, Consumable(parent: error), objc_AssociationPolicy(OBJC_ASSOCIATION_RETAIN))
380386
}
381387
}
382388

0 commit comments

Comments
 (0)