This file contains hidden or 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 SwiftUI | |
public struct AlertModifier: ViewModifier { | |
@Binding var showAlert: Bool | |
var error: Error? | |
public func body(content: Content) -> some View { | |
content | |
.alert("", isPresented: $showAlert) { | |
Button("Close", role: .cancel) {} |
This file contains hidden or 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 SwiftUI | |
struct FailureView: View { | |
@State var isShowSheet = false | |
@State var shareData: String? | |
var body: some View { | |
Button("Change(Fail)") { | |
shareData = "Show this message" | |
isShowSheet = true |
This file contains hidden or 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 UIKit | |
enum Temp { | |
case one | |
} | |
enum Number: Int { | |
case one | |
} |
This file contains hidden or 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
// Thread 1: Simultaneous accesses to 0x7fcf738afc10, but modification requires exclusive access |
This file contains hidden or 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
let button = UIButton(type: .custom) | |
button.setContentCompressionResistancePriority(.required, for: .horizontal) | |
// (参考) | |
// https://medium.com/eureka-engineering/ios%E3%82%A8%E3%83%B3%E3%82%B8%E3%83%8B%E3%82%A2%E5%BF%85%E8%A6%8B-ios%E3%81%AE%E3%83%AC%E3%82%A4%E3%82%A2%E3%82%A6%E3%83%88%E3%81%A7%E6%8A%BC%E3%81%95%E3%81%88%E3%81%A6%E3%81%8A%E3%81%8D%E3%81%9F%E3%81%84%E3%81%93%E3%81%A8-%E7%B7%8F%E9%9B%86%E7%B7%A8-b25342566ccc | |
// https://qiita.com/shiz/items/523e3741899e9607c26f |
This file contains hidden or 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
final class SomeStore { | |
static let key = "xxx" | |
private let userDefaults: UserDefaults | |
init(userDefaults: UserDefaults = .standard) { | |
self.userDefaults = userDefaults | |
} | |
func set(some: String) { | |
userDefaults.set(some, forKey: Self.key) |
This file contains hidden or 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 UIKit | |
// official document | |
// https://developer.apple.com/documentation/swift/array/3126951-insert | |
// safe! | |
var array = [0, 1, 2, 3, 4, 5, 6] | |
array.insert(7, at: 7) | |
print(array) |
This file contains hidden or 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
let size = systemLayoutSizeFitting(UIView.layoutFittingCompressedSize) |
This file contains hidden or 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
// 基本的にはinfo.plistで設定できる | |
// | |
// iPadだけで別に設定することも可 | |
// https://developer.apple.com/documentation/uikit/uiviewcontroller/1621435-supportedinterfaceorientations | |
// Supported interface orientations | |
// Supported interface orientations (iPad) |
NewerOlder