Commit 7a203357 by Sarkizz

移除某些方法返回值忽略警告

parent 7fd14045
......@@ -139,9 +139,10 @@ extension UIView {
}
public func addLine(position: LinePosition = .bottom(offset: 0, style: .full), width: CGFloat = 1) {
let _ = line(position: position, width: width)
line(position: position, width: width)
}
@discardableResult
public func line(position: LinePosition, width: CGFloat = 1) -> BorderLine {
if let line = viewWithTag(position.tag) as? BorderLine {
return line
......
......@@ -100,6 +100,7 @@ extension CBPeripheral {
}
}
@discardableResult
public func observerValue(_ chars: CBCharacteristic, change: @escaping BLECharsValueBlock) -> Bool {
if delegate != nil && chars.observerable {
CBPeripheral._charsValueObservers[chars.observerKey] = change
......@@ -188,7 +189,7 @@ extension CBPeripheral {
if error != nil {
change(self, nil, error)
} else if let c = chars?.first {
let _ = self.observerValue(c, change: change)
self.observerValue(c, change: change)
} else {
change(p, nil, self.error(code: .notfound, desc: "未找到对应特征"))
}
......
......@@ -72,6 +72,7 @@ extension MRFiles {
}
}
@discardableResult
public class func syncCreateDirectory(_ url: URL, force: Bool = true) -> Error? {
if force, url.isURLExists() {
if let error = syncDelete(url) {
......@@ -95,6 +96,7 @@ extension MRFiles {
}
}
@discardableResult
public class func syncWrite(to url: URL, data: Data?, force: Bool = true) -> Error? {
if force, url.isURLExists() {
if let err = syncDelete(url) {
......@@ -124,6 +126,7 @@ extension MRFiles {
}
}
@discardableResult
public class func syncDelete(_ url: URL) -> Error? {
do {
try FileManager.default.removeItem(at: url)
......@@ -142,6 +145,7 @@ extension MRFiles {
}
}
@discardableResult
public class func syncCopy(src: URL, to: URL, force: Bool = true) -> Error? {
if !src.isURLExists() {
return error(.notExists, msg: "复制文件不存在")
......@@ -168,6 +172,7 @@ extension MRFiles {
}
}
@discardableResult
public class func syncCopyItems(fromDic: URL, toDic: URL, filter: MRFilesFilterBlock? = nil) -> Error? {
guard fromDic.isURLExists(), toDic.isURLExists() else {
return error(.notExists, msg: "目录不存在")
......@@ -196,6 +201,7 @@ extension MRFiles {
}
}
@discardableResult
public class func syncMove(src: URL, to: URL, force: Bool = true) -> Error? {
if !src.isURLExists() {
return error(.notExists, msg: "移动文件不存在")
......@@ -222,6 +228,7 @@ extension MRFiles {
}
}
@discardableResult
public class func syncMoveItems(fromDic: URL, toDic: URL, filter: MRFilesFilterBlock? = nil) -> Error? {
guard fromDic.isURLExists(), toDic.isURLExists() else {
return error(.notExists, msg: "目录不存在")
......@@ -250,6 +257,7 @@ extension MRFiles {
}
}
@discardableResult
public class func syncLink(src: URL, to: URL, force: Bool = true) -> Error? {
if !src.isURLExists() {
return error(.notExists, msg: "链接文件不存在")
......@@ -279,6 +287,7 @@ extension MRFiles {
}
}
@discardableResult
public class func syncContents(of fileURL: URL) -> (Data?, Error?) {
if !fileURL.isURLExists() {
return (nil, error(.notExists, msg: "文件不存在"))
......@@ -291,6 +300,7 @@ extension MRFiles {
}
}
@discardableResult
public class func syncHash(of fileURL: URL) -> String? {
let rs = syncContents(of: fileURL)
if let data = rs.0 {
......@@ -339,6 +349,7 @@ extension String {
return FileManager.default.isWritableFile(atPath: self)
}
@discardableResult
public func syncWriteToFile(_ url: URL, force: Bool = true) -> Error? {
return MRFiles.syncWrite(to: url, data: data(using: .utf8), force: force)
}
......@@ -357,6 +368,7 @@ extension URL {
return FileManager.default.isWritableFile(atPath: path)
}
@discardableResult
public func syncCreate(force: Bool = true, isDirectory: Bool = true) -> Error? {
if isDirectory {
return MRFiles.syncCreateDirectory(self, force: force)
......@@ -373,6 +385,7 @@ extension URL {
}
}
@discardableResult
public func syncCopy(to url: URL, force: Bool = true) -> Error? {
return MRFiles.syncCopy(src: self, to: url, force: force)
}
......@@ -381,6 +394,7 @@ extension URL {
MRFiles.asyncCopy(src: self, to: url, force: force, finish: finish)
}
@discardableResult
public func syncCopyItems(to url: URL, filter: MRFilesFilterBlock? = nil) -> Error? {
return MRFiles.syncCopyItems(fromDic: self, toDic: url, filter: filter)
}
......@@ -389,6 +403,7 @@ extension URL {
MRFiles.asyncCopyItems(fromDic: self, toDic: url, filter: filter, finish: finish)
}
@discardableResult
public func syncMove(to url: URL, force: Bool = true) -> Error? {
return MRFiles.syncMove(src: self, to: url, force: force)
}
......@@ -397,6 +412,7 @@ extension URL {
MRFiles.asyncMove(src: self, to: url, force: force, finish: finish)
}
@discardableResult
public func syncMoveItems(to url: URL, filter: MRFilesFilterBlock? = nil) -> Error? {
return MRFiles.syncMoveItems(fromDic: self, toDic: url, filter: filter)
}
......@@ -405,6 +421,7 @@ extension URL {
MRFiles.asyncMoveItems(fromDic: self, toDic: url, filter: filter, finish: finish)
}
@discardableResult
public func syncDelete() -> Error? {
return MRFiles.syncDelete(self)
}
......@@ -423,6 +440,7 @@ extension URL {
}
extension Data {
@discardableResult
public func syncWrite(to url: URL, force: Bool = true) -> Error? {
return MRFiles.syncWrite(to: url, data: self, force: force)
}
......
......@@ -16,14 +16,14 @@ class MRFilesTests: XCTestCase {
override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.
if let url = documentURL {
let _ = MRFiles.syncCreateDirectory(url)
MRFiles.syncCreateDirectory(url)
}
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
if let url = documentURL {
let _ = MRFiles.syncDelete(url)
MRFiles.syncDelete(url)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment