✅ [Accepted] Solution for Swift
\nDisclaimer: By using any content from this post or thread, you release the author(s) from all liability and warranty of any kind. You are free to use the cont
<blockquote>\n<b>Disclaimer:</b> By using any content from this post or thread, you release the author(s) from all liability and warranty of any kind. You are free to use the content freely and as you see fit. Any suggestions for improvement are welcome and greatly appreciated! Happy coding!\n</blockquote>\n\n```swift\nclass Solution {\n    func fourSum(_ nums: [Int], _ target: Int) -> [[Int]] {\n        let len = nums.count\n        guard len >= 4 else { return [] }\n        \n        var result = [[Int]]()\n        let sort = nums.sorted()\n        \n        for a in 0..<(len - 1) where a == 0 || sort[a] != sort[a-1] {\n            for b in (a + 1)..<len where b == a + 1 || sort[b] != sort[b-1] {\n                var c = b + 1, d = len - 1\n                while c < d {\n                    let val = (a: sort[a], b: sort[b], c: sort[c], d: sort[d])\n                    let sum = (val.a + val.b + val.c + val.d)\n                    if sum == target { result.append([val.a,val.b,val.c,val.d]) }\n                    if sum < target {\n                        while sort[c] == val.c, c < d { c += 1 }\n                    } else {\n                        while sort[d] == val.d, d > b { d -= 1 }\n                    }\n                }\n            }\n        }\n        return result\n    }\n}\n```\n\n---\n\n<details>\n<summary>\n<img src="https://git.io/JDblm" height="24">\n<b>TEST CASES</b>\n</summary>\n\n<pre>\n<b>Result:</b> Executed 2 tests, with 0 failures (0 unexpected) in 0.010 (0.012) seconds\n</pre>\n\n```swift\nimport XCTest\n\nclass Tests: XCTestCase {\n    \n    private let solution = Solution()\n    \n    func test0() {\n        let value = solution.fourSum([1,0,-1,0,-2,2], 0)\n        XCTAssertEqual(value, [[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]])\n    }\n    func test1() {\n        let value = solution.fourSum([2,2,2,2,2], 8)\n        XCTAssertEqual(value, [[2,2,2,2]])\n    }\n}\n\nTests.defaultTestSuite.run()\n```\n\n</details>
['Swift']