Skip to content

Commit

Permalink
update swift 5!
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfeedface1993 committed Mar 27, 2019
1 parent caedac0 commit f759e8e
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 33 deletions.
4 changes: 2 additions & 2 deletions CCCHOOO/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ViewController: NSViewController {
// "http://www.88pan.cc/file-532359.html",
// "http://www.ccchoo.com/file-40055.html",
// "http://www.ccchoo.com/file-40053.html"]http://www.chooyun.com/file-51745.html
let items = ["http://www.567pan.com/file-140318.html"]//, "http://www.chooyun.com/file-51745.html", "http://www.feemoo.com/s/v2j0z15j", "http://www.ccchoo.com/file-40052.html", "http://www.feemoo.com/file-1897522.html"
let items = ["http://www.567pan.com/file-156781.html"]//, "http://www.chooyun.com/file-51745.html", "http://www.feemoo.com/s/v2j0z15j", "http://www.ccchoo.com/file-40052.html", "http://www.feemoo.com/file-1897522.html"
// let items = ["http://www.chooyun.com/file-96683.html"]
for item in items {
if let _ = pipline.add(url: item, password: "") {
Expand Down Expand Up @@ -185,7 +185,7 @@ extension ViewController : PCPiplineDelegate {
func add(info: DownloadInfo) {
if let items = DownloadStateController.content as? [DownloadInfo] {
var newItems = items
if let index = newItems.index(where: {
if let index = newItems.firstIndex(where: {
if let rif = $0.riffle {
return rif == info.riffle
}
Expand Down
4 changes: 2 additions & 2 deletions PowerCore/PCDownloadManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class PCDownloadManager: NSObject {
/// - Parameter task: HTTP下载任务
/// - Returns: 若找不到则返回nil
func findTask(withDownloadTask task: URLSessionDownloadTask) -> Int? {
return tasks.index(where: {
return tasks.firstIndex(where: {
if let url = $0.task.currentRequest?.url?.absoluteString {
return (task.response?.url?.absoluteString ?? "") == url
}
Expand All @@ -98,7 +98,7 @@ public class PCDownloadManager: NSObject {
}

func remove(fromRiffle riffle: PCWebRiffle) {
if let index = tasks.index(where: { $0.request.riffle == riffle }) {
if let index = tasks.firstIndex(where: { $0.request.riffle == riffle }) {
tasks[index].task.cancel()
tasks.remove(at: index)
}
Expand Down
12 changes: 6 additions & 6 deletions PowerCore/PCPipline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class PCPiplineSeat {
run()
}

guard let _ = PCDownloadManager.share.tasks.index(where: { $0.request.riffle?.mainURL == finished.last!.mainURL && $0.request.isFileDownloadTask }) else {
guard let _ = PCDownloadManager.share.tasks.firstIndex(where: { $0.request.riffle?.mainURL == finished.last!.mainURL && $0.request.isFileDownloadTask }) else {
pipline.delegate?.pipline?(didFinishedRiffle: finished.last!)
return
}
Expand Down Expand Up @@ -113,7 +113,7 @@ public class PCPiplineSeat {
}

func remove(riffle: PCWebRiffle) {
if let index = working.index(where: { $0.host == riffle.host }) {
if let index = working.firstIndex(where: { $0.host == riffle.host }) {
if index == working.startIndex {
working[index].downloadFinished()
} else {
Expand All @@ -123,11 +123,11 @@ public class PCPiplineSeat {
}

public func restart(mainURL: URL) {
if let index = finished.index(where: { $0.mainURL == mainURL }) {
if let index = finished.firstIndex(where: { $0.mainURL == mainURL }) {
let item = finished[index]
item.isFinished = false
let downloadManager = PCDownloadManager.share
if let downloadIndex = downloadManager.tasks.index(where: { $0.request.riffle?.mainURL == mainURL }) {
if let downloadIndex = downloadManager.tasks.firstIndex(where: { $0.request.riffle?.mainURL == mainURL }) {
print("########### Remove Download Task for \(mainURL.absoluteString) ###########")
downloadManager.tasks.remove(at: downloadIndex)
}
Expand Down Expand Up @@ -233,7 +233,7 @@ public class PCPipeline {
/// - Parameter riffle: riffle对象
/// - Returns: 若没有对应的位置,则返回nil
func find(withRiffle riffle: PCWebRiffle) -> Int? {
return workers.index(where: { (seat) -> Bool in
return workers.firstIndex(where: { (seat) -> Bool in
return (seat.finished.first(where: { $0.host == riffle.host }) != nil) || (seat.working.first(where: { $0.host == riffle.host }) != nil)
})
}
Expand All @@ -243,7 +243,7 @@ public class PCPipeline {
/// - Parameter Hose: 站点类型
/// - Returns: 位置
func find(withHost Hose: WebHostSite) -> Int? {
return workers.index(where: { (seat) -> Bool in
return workers.firstIndex(where: { (seat) -> Bool in
if let ff = seat.finished.first {
return ff.host == Hose
}
Expand Down
16 changes: 9 additions & 7 deletions WebShellExsample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,12 @@
TargetAttributes = {
24E60F1521D66180007AB419 = {
CreatedOnToolsVersion = 10.1;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
27448B2220170ABA001FC925 = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
277C843A2046A45A00D7B2B1 = {
Expand All @@ -577,7 +579,7 @@
};
27C9DBBB204146A100A87E9E = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -821,7 +823,7 @@
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.ascp.WebShellCoreTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -838,7 +840,7 @@
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.ascp.WebShellCoreTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down Expand Up @@ -969,7 +971,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ascp.CCCHOOO;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -986,7 +988,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ascp.CCCHOOO;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down Expand Up @@ -1101,7 +1103,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = macosx;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VALID_ARCHS = "i386 x86_64";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -1128,7 +1130,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = macosx;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VALID_ARCHS = "i386 x86_64";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "CCCHOOO/ViewController.swift"
timestampString = "568734265.92786"
timestampString = "571378218.275089"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "54"
Expand Down Expand Up @@ -58,7 +58,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "PowerCore/PCPipline.swift"
timestampString = "567699851.06293"
timestampString = "571377966.556281"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "64"
Expand All @@ -74,7 +74,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "PowerCore/PCPipline.swift"
timestampString = "567699851.0629801"
timestampString = "571377966.556618"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "63"
Expand Down Expand Up @@ -170,7 +170,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "PowerCore/PCDownloadManager.swift"
timestampString = "568734265.928038"
timestampString = "571378218.275362"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "187"
Expand Down Expand Up @@ -202,7 +202,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "PowerCore/PCDownloadManager.swift"
timestampString = "568734265.928104"
timestampString = "571378218.27549"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "51"
Expand Down Expand Up @@ -330,7 +330,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "666pan/Pan666.swift"
timestampString = "568734265.928352"
timestampString = "571378218.275635"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "145"
Expand All @@ -339,5 +339,101 @@
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "666pan/Pan666.swift"
timestampString = "571378218.276188"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "73"
endingLineNumber = "73"
landmarkName = "load666PanSequence()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "666pan/Pan666.swift"
timestampString = "571378218.2766629"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "79"
endingLineNumber = "79"
landmarkName = "load666PanSequence()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "666pan/Pan666.swift"
timestampString = "571378218.276991"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "72"
endingLineNumber = "72"
landmarkName = "load666PanSequence()"
landmarkType = "7">
<Locations>
<Location
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "WebShell_macOS.Pan666.load666PanSequence() -&gt; ()"
moduleName = "WebShell_macOS"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/virus1994/GitHub/WebShell/666pan/Pan666.swift"
timestampString = "571378181.6520489"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "72"
endingLineNumber = "72"
offsetFromSymbolStart = "22">
</Location>
<Location
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #1 (WebShell_macOS.PCDownloadTask) -&gt; () in WebShell_macOS.Pan666.load666PanSequence() -&gt; ()"
moduleName = "WebShell_macOS"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/virus1994/GitHub/WebShell/666pan/Pan666.swift"
timestampString = "571378181.6542031"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "72"
endingLineNumber = "72"
offsetFromSymbolStart = "33">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "PowerCore/PCDownloadManager.swift"
timestampString = "571378218.277347"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "96"
endingLineNumber = "96"
landmarkName = "add(request:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,11 @@
<key>orderHint</key>
<integer>4</integer>
</dict>
<key>WebShellExample-iOS.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
</dict>
<key>WebShellExample-iOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
</dict>
<key>WebShellExsample.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
</dict>
<key>WebShellExsample.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
Expand Down

0 comments on commit f759e8e

Please sign in to comment.