Compare commits
10 Commits
nt/queuein
...
fix-NSErro
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46451dde7d | ||
|
|
ef9b9ee63d | ||
|
|
59997dd6d9 | ||
|
|
6c954ab704 | ||
|
|
aea48ea185 | ||
|
|
f6b15b7626 | ||
|
|
817ea8c3f4 | ||
|
|
953665d28b | ||
|
|
f9cc0d67dc | ||
|
|
f95e7b2614 |
@ -173,7 +173,7 @@ When you have a series of tasks to perform on an array of data:
|
||||
```swift
|
||||
// fade all visible table cells one by one in a “cascading” effect
|
||||
|
||||
let fade = Guarantee()
|
||||
var fade = Guarantee()
|
||||
for cell in tableView.visibleCells {
|
||||
fade = fade.then {
|
||||
UIView.animate(.promise, duration: 0.1) {
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 0ac0b16d20c67a43cd5dfd67ea73304f9b0b31c8
|
||||
Subproject commit e26f6a55921ea671855093754686991b08ef97cc
|
||||
@ -620,7 +620,7 @@
|
||||
6399A3721D595D9100D65233 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 1100;
|
||||
LastUpgradeCheck = 1200;
|
||||
TargetAttributes = {
|
||||
630019011D596292003B4E30 = {
|
||||
LastSwiftMigration = 1100;
|
||||
@ -815,12 +815,12 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.12;
|
||||
SWIFT_INSTALL_OBJC_HEADER = NO;
|
||||
TVOS_DEPLOYMENT_TARGET = 10.0;
|
||||
TVOS_DEPLOYMENT_TARGET = 12.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@ -828,12 +828,12 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.12;
|
||||
SWIFT_INSTALL_OBJC_HEADER = NO;
|
||||
TVOS_DEPLOYMENT_TARGET = 10.0;
|
||||
TVOS_DEPLOYMENT_TARGET = 12.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@ -925,6 +925,7 @@
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
@ -947,7 +948,7 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
LD_DYLIB_INSTALL_NAME = "@rpath";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
@ -958,7 +959,7 @@
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 4.0;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
TVOS_DEPLOYMENT_TARGET = 12.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||
};
|
||||
@ -986,6 +987,7 @@
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
@ -1006,7 +1008,7 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
LD_DYLIB_INSTALL_NAME = "@rpath";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.promisekit;
|
||||
@ -1015,7 +1017,7 @@
|
||||
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos watchsimulator iphonesimulator watchos iphoneos";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 4.0;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
TVOS_DEPLOYMENT_TARGET = 12.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1100"
|
||||
LastUpgradeVersion = "1200"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@ -29,15 +29,6 @@
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
codeCoverageEnabled = "YES"
|
||||
onlyGenerateCoverageForSpecifiedTargets = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "63B0AC561D595E1B00FA21D9"
|
||||
BuildableName = "PromiseKit.framework"
|
||||
BlueprintName = "PromiseKit"
|
||||
ReferencedContainer = "container:PromiseKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<CodeCoverageTargets>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <dispatch/dispatch.h>
|
||||
#import "fwd.h"
|
||||
#import <PromiseKit/fwd.h>
|
||||
|
||||
/// INTERNAL DO NOT USE
|
||||
@class __AnyPromise;
|
||||
|
||||
@ -3,7 +3,7 @@ import Foundation
|
||||
/**
|
||||
__AnyPromise is an implementation detail.
|
||||
|
||||
Because of how ObjC/Swift compatability work we have to compose our AnyPromise
|
||||
Because of how ObjC/Swift compatibility work we have to compose our AnyPromise
|
||||
with this internal object, however this is still part of the public interface.
|
||||
Sadly. Please don’t use it.
|
||||
*/
|
||||
|
||||
@ -83,9 +83,10 @@ extension Error {
|
||||
} catch CocoaError.userCancelled {
|
||||
return true
|
||||
} catch {
|
||||
#if os(macOS) || os(iOS) || os(tvOS)
|
||||
let pair = { ($0.domain, $0.code) }(error as NSError)
|
||||
return ("SKErrorDomain", 2) == pair
|
||||
#if canImport(StoreKit)
|
||||
let domain = (error as AnyObject).value(forKey: "domain") as? String
|
||||
let code = (error as AnyObject).value(forKey: "code") as? Int
|
||||
return ("SKErrorDomain", 2) == (domain, code)
|
||||
#else
|
||||
return false
|
||||
#endif
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#import "fwd.h"
|
||||
#import "AnyPromise.h"
|
||||
#import <PromiseKit/fwd.h>
|
||||
#import <PromiseKit/AnyPromise.h>
|
||||
|
||||
#import <Foundation/NSObjCRuntime.h> // `FOUNDATION_EXPORT`
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ import Dispatch
|
||||
URLSession.shared.dataTask(url: url3)
|
||||
}
|
||||
|
||||
- Note: the block you pass excecutes immediately on the current thread/queue.
|
||||
- Note: the block you pass executes immediately on the current thread/queue.
|
||||
*/
|
||||
public func firstly<U: Thenable>(execute body: () throws -> U) -> Promise<U.T> {
|
||||
do {
|
||||
|
||||
@ -139,7 +139,7 @@ public func when<It: IteratorProtocol>(fulfilled promiseIterator: It, concurrent
|
||||
}
|
||||
|
||||
var generator = promiseIterator
|
||||
var root = Promise<[It.Element.T]>.pending()
|
||||
let root = Promise<[It.Element.T]>.pending()
|
||||
var pendingPromises = 0
|
||||
var promises: [It.Element] = []
|
||||
|
||||
@ -154,15 +154,11 @@ public func when<It: IteratorProtocol>(fulfilled promiseIterator: It, concurrent
|
||||
}
|
||||
guard shouldDequeue else { return }
|
||||
|
||||
var index: Int!
|
||||
var promise: It.Element!
|
||||
|
||||
barrier.sync(flags: .barrier) {
|
||||
guard let next = generator.next() else { return }
|
||||
|
||||
promise = next
|
||||
index = promises.count
|
||||
|
||||
pendingPromises += 1
|
||||
promises.append(next)
|
||||
}
|
||||
|
||||
@ -2,6 +2,10 @@ import Foundation
|
||||
import PromiseKit
|
||||
import XCTest
|
||||
|
||||
#if canImport(StoreKit)
|
||||
import StoreKit
|
||||
#endif
|
||||
|
||||
class CancellationTests: XCTestCase {
|
||||
func testCancellation() {
|
||||
let ex1 = expectation(description: "")
|
||||
@ -95,6 +99,25 @@ class CancellationTests: XCTestCase {
|
||||
waitForExpectations(timeout: 1)
|
||||
}
|
||||
|
||||
func testDoesntCrashSwift() {
|
||||
// Previously exposed a bridging crash in Swift
|
||||
// NOTE nobody was brave enough or diligent enough to report this to Apple :{
|
||||
XCTAssertFalse(NSError().isCancelled)
|
||||
|
||||
#if canImport(StoreKit)
|
||||
do {
|
||||
let err = SKError(.paymentCancelled)
|
||||
XCTAssertTrue(err.isCancelled)
|
||||
throw err
|
||||
} catch {
|
||||
XCTAssertTrue(error.isCancelled)
|
||||
}
|
||||
|
||||
XCTAssertFalse(SKError(.clientInvalid).isCancelled)
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#if swift(>=3.2)
|
||||
func testIsCancelled() {
|
||||
XCTAssertTrue(PMKError.cancelled.isCancelled)
|
||||
|
||||
@ -18,6 +18,7 @@ extension CancellationTests {
|
||||
// to regenerate.
|
||||
static let __allTests__CancellationTests = [
|
||||
("testCancellation", testCancellation),
|
||||
("testDoesntCrashSwift", testDoesntCrashSwift),
|
||||
("testFoundationBridging1", testFoundationBridging1),
|
||||
("testFoundationBridging2", testFoundationBridging2),
|
||||
("testIsCancelled", testIsCancelled),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user