Swiftpack.co - Package - Sizuha/SizUtil-iOS

SizUtil

Utilities for iOS

Requirements

  • iOS 8.0+
  • XCode 11.0+
  • Swift 5

Installation

Swift Package Manager

Go to Project -> Swift Packages and add the repository:

https://github.com/Sizuha/SizUtil-iOS

HTTP通信

import SizUtil

var params = [String : String?](https://raw.github.com/Sizuha/SizUtil-iOS/blob/master/)
SizHttp.post(url: url, params: params) { data: Data?, response: URLResponse?, error: Eror? in
	if let data = data {
		let jsonData: [String : Any]? = 
			try? JSONSerialization.jsonObject(
				with: data, 
				options: .allowFragments
			) as? [String : Any]
		//...
	}
	//...
}

日付と時間

Calendar

import SizUtil // 以降、import文は省略

let cal = Calendar.standard

日付

let ymd = SizYearMonthDay(2020, 2, 10) // 2020年2月10日
let year: Int = ymd.year
let month: Int = ymd.month
let day: Int = ymd.day

let date: Date? = ymd.toDate()

let today = Date()
let today_ymd = SizYearMonthDay(from: today)

時間

let hms = SizHourMinSec(hour: 23, minute: 10, second: 15) // 23時10分15秒
let hour = hms.hour
let min = hms.minute
let sec = hms.second

let intVal: Int = hms.toInt() // -> 231015

let today = Date()
let today_hms = SizHourMinSec(from: today)

正規表現(文字列のパターン)

let pattern = ?="ここに正規表現式を書く"
if pattern ~= inputString /* String */ {
	// パターンが一致!!
}

iCloud Backupから除く

URL(fileURLWithPath: "...").setExcludedFromBackup()

Github

link
Stars: 0

Dependencies

Used By

Total: 0