The Composable Architecture (省略すると TCA) は、コンポジション、テスト、開発者にとっての使いやすさを考慮し、一貫性のある理解しやすい方法でアプリケーションを構築するためのライブラリです。SwiftUI、UIKit などで使用することができ、Apple のどのプラットフォーム (iOS, macOS, tvOS, watchOS) でも使用
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Combine | |
import UIKit | |
public protocol CombineCompatible {} | |
// MARK: - UIControl | |
public extension UIControl { | |
final class Subscription<SubscriberType: Subscriber, Control: UIControl>: Combine.Subscription where SubscriberType.Input == Control { | |
private var subscriber: SubscriberType? | |
private let input: Control |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PlaygroundSupport | |
import SwiftUI | |
import Combine | |
class ObservableObject1: ObservableObject { | |
@Published var name: String = "src" | |
} | |
struct ContentView1: View { | |
@ObservedObject private var object = ObservableObject1() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to: | |
// 1. Open the Firebase Analytics Dashboard | |
// 2. Scroll to bottom, where you see the "Users by Device model" widget | |
// 3. Click "View device models" in that widget (this opens the "Tech details" Firebase Analytics page) | |
// 4. Above the table shown in the new page, click on the “Device model” drop down menu and select “OS with Version” | |
// 5. Make sure to select “OS with version” and not “OS Version” | |
// 6. On the top right corner of the page, click on the “Share this report” icon (next to the date) | |
// 7. Click “Download file” on the new side bar, then “Download CSV" | |
// 8. Open the file and select the iOS/Android breakdown raw data | |
// 9. Replace the sample data in this script with your data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Array { | |
func chunked(by chunkSize: Int) -> [[Element]] { | |
return stride(from: 0, to: self.count, by: chunkSize).map { | |
Array(self[$0..<Swift.min($0 + chunkSize, self.count)]) | |
} | |
} | |
} | |
let arr = [0,1,2,3,4,5,6,7,8,9] | |
print(arr.chunked(by: 2)) // [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView { | |
func roundCorners(_ corners: CACornerMask, radius: CGFloat) { | |
if #available(iOS 11, *) { | |
self.layer.cornerRadius = radius | |
self.layer.maskedCorners = corners | |
} else { | |
var cornerMask = UIRectCorner() | |
if(corners.contains(.layerMinXMinYCorner)){ | |
cornerMask.insert(.topLeft) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | |
let text = collections[indexPath.row].name | |
let width = UILabel.textWidth(font: titleFont, text: text) | |
return CGSize(width: width + left + right, height: height) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 日本語入力設定 | |
if has('multi_byte_ime') || has('xim') | |
" IME ON時のカーソルの色を設定(設定例:紫) | |
highlight CursorIM guibg=Purple guifg=NONE | |
" 挿入モード・検索モードでのデフォルトのIME状態設定 | |
set iminsert=0 imsearch=0 | |
" 挿入モードでのIME状態を記憶させない | |
inoremap <silent> <ESC> <ESC>:set iminsert=0<CR> | |
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// by calling [NSURLProtocol registerClass:[MyURLProtocol class]]; in -application:didFinishLoadingWithOptions:, your protocol will have priority over any of the built-in protocols. | |
URLProtocol.registerClass(ActivityURLProtocol.self) | |
//URLProtocol.unregisterClass(ActivityURLProtocol.self) | |
print(URLSession.shared.configuration.protocolClasses) | |
} |
NewerOlder