lang
stringclasses 10
values | seed
stringlengths 5
2.12k
|
---|---|
swift | // FXKit
//
// Created by Fanxx on 2019/11/23.
//
import UIKit
public protocol FXViewControllerType: UIViewController {
///进入场景,除非特殊情况由调用方设置,一般建议自己定义自己的场景或使用默认
var segue: FXPresentSegue { get }
///设置进入该页面的权限
var preconditions : [FXViewControllerPrecondition]? { get }
}
|
swift | // LobstersReader
//
// Created by Colin Drake on 6/25/17.
// Copyright © 2017 Colin Drake. All rights reserved.
//
import Foundation
import Result |
swift | func loadAnchorData(_ isGroup: Bool, _ urlString: String, _ parameters: [String: Any]? = nil, completion: @escaping () -> ()) {
NetworkTools.request(.get, urlString, parameters) { [weak self] (result) in
guard let resultDict = result as? [String: Any] else { return }
guard let dataArray = resultDict["data"] as? [[String: Any]] else { return }
if isGroup {
for dict in dataArray {
self?.anchorGroups.append(AnchorGroup(dict))
}
} else {
let group = AnchorGroup() |
swift | override func setUp() {
super.setUp()
Localize.update(provider: .strings)
Localize.update(language: "en")
Localize.update(fileName: "Other")
Localize.update(bundle: Bundle(for: type(of: self)))
}
func testKeyInOtherLanguage() {
let localized = "hello.baby".localize()
XCTAssertTrue(localized == "This is a welcome, new baby is here!")
} |
swift | // LookHomeVRDemo
//
// Created by aaron on 2020/4/16.
// Copyright © 2020 aaron. All rights reserved.
//
import UIKit
|
swift | var deprecatedToValidIdentifier = [String: String]()
for (key, value) in validationResults.flatMap({ $0.deprecatedToValidIDPairs }) {
deprecatedToValidIdentifier[key] = value
}
if let cache = cache, let path = file.path {
cache.cache(violations: violations, forFile: path, configuration: configuration) |
swift | */
public func run(_ command: String, settingsBlock: (RunSettings) -> Void) -> RunResults {
return Runner.run(command, settings: settingsBlock)
}
/**
Executes a command and captures its output
- parameter command: the command to execute
- parameter args: the parameters to pass to the command
- parameter settingsBlock: block that receives the settings to costumize the behavior of run
|
swift | Spacer()
PutBox(playUiSide: uiSide(at: .s2))
.frame(width: proxy.size.width * 0.25)
}
Spacer()
}
}
.padding()
|
swift |
enum B {
func f<C() {
class A {
class C: A? {
let h>Bool](start, """)
protocol b {
class B = B, f<Int>(a<S {
}
func g<T : String):
}
}
let h: a {
return { |
swift | private func showAccessibilityFocus() {
guard let accessibleMessage = view as? AccessibleMessage,
let focus = accessibleMessage.accessibilityElement ?? accessibleMessage.additonalAccessibilityElements?.first else { return }
UIAccessibility.post(notification: UIAccessibility.Notification.layoutChanged, argument: focus)
}
|
swift |
output.searchDescription
.bind(to: navigationItem.rx.title)
.disposed(by: disposeBag)
|
swift | .then { [weak self] kin in
self?.lastBalance = Balance(amount: kin)
p.signal(kin)
}
.error { error in
p.signal(error)
}
|
swift | dashTwoLayer.position = layer.position
}
func rotationAnimation(_ angle: CGFloat) -> CABasicAnimation {
var animation : CABasicAnimation
if #available(iOS 9.0, *) {
let springAnimation = CASpringAnimation(keyPath:"transform.rotation.z")
springAnimation.damping = 1.5
springAnimation.mass = 0.22
springAnimation.initialVelocity = 0.5
animation = springAnimation
} else { |
swift | // MessagesHelperMethods.swift
// ABC
//
// Created by Cedric Bahirwe on 11/18/20.
// Copyright © 2020 Cedric Bahirwe. All rights reserved.
//
import Foundation
import UIKit
import MultipeerConnectivity
|
swift |
NotificationCenter.default.addObserver(forName: .newDataVerbose, object: nil, queue: nil) { (notif) -> Void in
Swift.print("#mj.newData verbose notif")
let wantsVerbose = UserDefaults.standard.bool(forKey: C.PREF_VERBOSEOUTPUT) |
swift | "UIRequiredDeviceCapabilities": ["armv7"],
"UISupportedInterfaceOrientations": [
"UIInterfaceOrientationPortrait",
"UIInterfaceOrientationLandscapeLeft",
"UIInterfaceOrientationLandscapeRight",
],
"UISupportedInterfaceOrientations~ipad": [
"UIInterfaceOrientationPortrait",
"UIInterfaceOrientationPortraitUpsideDown",
"UIInterfaceOrientationLandscapeLeft",
"UIInterfaceOrientationLandscapeRight",
], |
swift | import SwiftUI
struct ItemView: View {
var width: CGFloat = 200
var height: CGFloat = 100
var name = ""
var backgroundColor: Color = .blue
var body: some View {
Text(name)
.foregroundColor(Color.white)
.frame(width: width, height: height, alignment: .center)
.background(backgroundColor)
.padding(.all, 1.0) |
swift | )
}
.navigationBarTitle("Your QR")
}
.onAppear {
let qrCodeData = self.viewModel.userProfileState.qrCodeData |
swift | class func photo(_ name: String, data: Data, completion: @escaping (_ error: Error?) -> Void) {
FireStorage.upload(data: data, dir: "media", name: name, ext: "jpg", completion: completion)
}
|
swift | let overview = DapanOverview.sharedInstance
DispatchQueue.main.async { [unowned self] in
self.dapanOverviewCell?.applyModel(overviewText: overview.overviewTex, status: overview.dapanStatus, badge: overview.dapanStatusBadge, action: overview.sugguestAction, cangwei: overview.sugguestCangWei)
self.dapanOverviewCell?.updateDragons(marketDragon: DataCache.marketDragon, gaoduDragon: DataCache.gaoduDragon)
self.dapanOverviewCell?.onDragonClicked = { [unowned self] (tag) in
let code:String? = tag == 1 ? DataCache.marketDragon?.code : DataCache.gaoduDragon?.code |
swift | import Foundation
import SwiftUI
struct WordsListItemView: View {
@Binding var word: Word
var body: some View {
VStack(alignment: .leading, spacing: 0) { |
swift | import Foundation
class C : Hive {}
// CHECK-LABEL: sil private @_T034objc_implicitly_unwrapped_optional1DCACSo7NSCoderC5coder_tcfcAA1CCSQyAHGSQyAEGAF_tcfcTV
// CHECK: bb0(%0 : $Optional<NSCoder>, %1 : $D): |
swift | }
XCTAssertNil(showInfoEffect)
// Ensure the info list modal is visible.
let (nextViewModel, _) = root.viewModel(for: [], at: displayTime)
guard case .info(_, .none) = nextViewModel.modal else {
XCTFail("Expected .info list, got \(nextViewModel.modal)")
return
}
// Show the license info.
let showAction: Root.Action = .infoListEffect(.showLicenseInfo)
let showEffect: Root.Effect?
do {
showEffect = try root.update(showAction) |
swift | //
// Created by Jesulonimi on 3/1/21.
//
import Foundation
public class AssetData:Codable{
public var index:Int64?;
public var params:AssetParamsData?; |
swift | // Look at the first element from the stack.
// Returns "Wade" since "Mike" was popped on the previous line.
stackOfNames.peek()
// Check to see if the stack is empty.
// Returns "false" since the stack still has elements in it. |
swift | func testIntegerTypeSizeIsItsWidthInBytes() {
expect{
try IntegerTypeSize().value()
}.to(
equal( |
swift | }
func same(n1: TreeNode?, n2: TreeNode?) -> Bool {
if n1 == nil && n2 == nil {
return true |
swift | layout.scrollDirection = .horizontal
}
}
|
swift | right[i] = nums[i + 1] * right[i + 1]
}
return (0..<nums.count).map { left[$0] * right[$0] }
}
}
// Tests
let s = Solution() |
swift | // Created by Nestor Hernandez on 2/20/19.
// Copyright © 2019 Nestor Hernandez. All rights reserved.
//
//MARK:- NOTES
/* This Struct will provide utility methods for appropiate Data Format.
It will Help the communication between layers
*/
import UIKit
protocol TransitionLayerProtocol {
}
struct TransitionLayer: TransitionLayerProtocol {
} |
swift | let decoder = JSONDecoder()
let jsonData = try decoder.decode([WatchList].self, from: dataObject)
promise(.success(jsonData))
print(jsonData)
} |
swift | }
extension JSON: NilLiteralConvertible {
public init(nilLiteral: ()) {
self.init(NSNull())
}
}
private let trueNumber = NSNumber(bool: true)
private let falseNumber = NSNumber(bool: false)
private let trueObjCType = String.fromCString(trueNumber.objCType)
private let falseObjCType = String.fromCString(falseNumber.objCType)
|
swift | import PackageDescription
let package = Package(
name: "HaishinKit",
dependencies: [
.Package(url: "https://github.com/shogo4405/Logboard.git", majorVersion: 1)
]
)
|
swift | public init(input: TW_Proto_BitcoinSigningInput) {
let inputData = TWDataCreateWithNSData(try! input.serializedData())
defer {
TWDataDelete(inputData)
}
rawValue = TWBitcoinTransactionSignerCreate(inputData)
}
deinit {
TWBitcoinTransactionSignerDelete(rawValue) |
swift | func assetPortraitCellSize(forViewSize size: CGSize) -> CGSize {
let count = CGFloat(assetPortraitColumnCount)
let edge = (size.width - (count - 1) * assetPortraitInteritemSpace) / count
return CGSize(width: edge, height: edge)
}
open var assetLandscapeColumnCount: Int = 7
open var assetLandscapeInteritemSpace: CGFloat = 1.5
open var assetLandscapeLineSpace: CGFloat = 1.5 |
swift |
// MARK: -
//---------------------------------------------------------------------------------------------------------------------------------------------
private class func updateRealm(_ realm: Realm, _ values: [String: Any], _ type: SyncObject.Type) {
|
swift | fetchChangesInZone() { result in
switch result {
case .success:
completion(.success(()))
case .failure(let error):
if case CloudKitZoneError.userDeletedZone = error {
self.createZoneRecord() { result in
switch result {
case .success:
self.refreshArticles(completion: completion) |
swift | }
func makeManager() -> HomePageManager {
return HomePageManager(provider: makeProvider())
}
func makeViewModel() -> HomePageViewModel { |
swift | do {
guard let filteredFileEnumerator = try fileEnumerator?.filter(filterClosure) as? [String] else {
print("Error filtering files.")
exit(2)
}
return filteredFileEnumerator
} catch { |
swift | /// Notwithstanding the foregoing, you may not use, copy, modify, merge, publish,
/// distribute, sublicense, create a derivative work, and/or sell copies of the
/// Software in any work that is designed, intended, or marketed for pedagogical or
/// instructional purposes related to programming, coding, application development,
/// or information technology. Permission for such use, copying, modification,
/// merger, publication, distribution, sublicensing, creation of derivative works,
/// or sale is expressly withheld. |
swift | import Darwin.C
#endif
enum ParsingState {
case endRequest
case startRequestContent
}
var hasError = false
var requestContent = ""
var reqid = -1
var state = ParsingState.endRequest
while let input = readLine() { |
swift | public var options: Options
public init(options: Options) {
self.options = options
super.init(service: GetBookmarkList.service) |
swift |
// MARK: - UIViewController Overrides
public final override func viewDidLoad() {
super.viewDidLoad()
fromDatePicker.datePickerMode = datePickerMode
toDatePicker.datePickerMode = datePickerMode
fromDatePicker.accessibilityIdentifier = "from date picker"
toDatePicker.accessibilityIdentifier = "to date picker"
if let fromDate = initialFromDate {
fromDatePicker.date = fromDate
} else { |
swift |
private func makeUpdateItemTypeViewController() -> CellItem {
return CellItem(title: "Dynamically change item type") { [unowned self] in
self.navigationController?.pushViewController(
UpdateItemTypeViewController(configuration: .default),
animated: true
) |
swift | )
return
}
if (error as NSError).code == NSURLErrorCancelled {
self.logger?.log( |
swift | audio.append(engine.render(duration: 1.0))
testMD5(audio)
}
func testDefault() {
let engine = AudioEngine() |
swift |
extension URI: Equatable {
@inlinable public static func == (lhs: URI, rhs: URI) -> Bool {
return lhs.__url == rhs.__url
}
}
extension URI: Hashable {
@inlinable public func hash(into hasher: inout Hasher) {
hasher.combine(__url)
} |
swift | //
// Created by ZJaDe on 2018/10/19.
// Copyright © 2018 zjade. All rights reserved.
//
import Foundation
infix operator ???: NilCoalescingPrecedence
public func ??? <T>(optional: T?, defaultValue: @autoclosure () -> String) -> String {
return optional.map { "\($0)" } ?? defaultValue()
}
infix operator <-
public func <- <T, E>(_ function: @escaping (T) -> E, parameters: T) -> () -> E { |
swift |
import Foundation
public class WfmUserScheduleAdherenceUpdatedTeamTopicUriReference: Codable {
public var _id: String?
public var name: String?
public init(_id: String?, name: String?) { |
swift | if redactValue {
result.append("[[redacted]]")
} else {
result.append(recursiveDescription(redact: redact, of: fieldValue))
}
}
result.append(")")
}
} else { |
swift | // Distributed under the terms of the MIT license
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// Test case found by fuzzing
import a}class B{
func a{protocol A{
typealias e:a
func a
struct
|
swift |
public struct FrontendError: BarcaError {
var innerError: Error
public init(_ error: Error) {
self.innerError = error
}
public var description: String {
switch innerError {
case let barcaError as BarcaError:
return barcaError.description
default: |
swift | let d3 = AOC20.Day03(raw: input)
let p2 = d3.p2()
XCTAssertEqual(p2, "336")
} |
swift | if case .text(let firstText) = self[firstIndex].kind {
var lastIndex = firstIndex
var concatenated = ""
while let next = self.index(lastIndex, offsetBy: 1, limitedBy: endIndex),
next < endIndex,
case .text(let nextText) = self[next].kind
{
defer { lastIndex = next }
concatenated.append(nextText.text.tokenKind.text)
}
|
swift |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
} |
swift | }
setContentView()
}
private func setContentView() {
myOrderListbannerScrollView.addSubview(myOrderListbannerContentView)
|
swift | case .terminal:
return TerminalApp()
case .iTerm:
return iTermApp()
case .hyper:
return HyperApp()
case .alacritty:
return AlacrittyApp()
}
}
}
public extension TerminalType {
|
swift | try configuration.apply(configuration: config)
let expectedKinds: Set<ImplicitReturnConfiguration.ReturnKind> = Set([
.closure,
.function,
.getter
]) |
swift | } _: {[weak self] in
guard let weakSelf = self else { return }
weakSelf.dataArray = []
//重现生成数据
weakSelf.refreshItemData()
//重现加载表格数据
weakSelf.tableView.reloadData() |
swift | }
}
guard let prefix = String(data: prefixData, encoding: .utf8) else {
return false
}
let bech32Result = bech32(prefix: prefix, data: outputdata)
guard let recovered = String(data: bech32Result, encoding: .utf8) else {
return false
} |
swift | // Copyright © 2020 sb. All rights reserved.
//
import UIKit
@UIApplicationMain
class GCAppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true |
swift | // Distributed under the terms of the MIT license
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// Test case found by fuzzing
func f{
class a{
class a{protocol a
func t{ |
swift | //
// Created by Bence Pattogató on 16/11/15.
// Copyright © 2015 Wintergarden. All rights reserved.
//
import Foundation |
swift |
func signUpViewController(signUpController: PFSignUpViewController, didSignUpUser user: PFUser) {
self.callback(user, nil)
}
} |
swift | if let objectToRemove = realm?.object(ofType: WatchlistModel.self, forPrimaryKey: object.id) {
LoggingHelper.register(event: .removeFromWatchlist, info: ["videoId": String(object.id)])
realm?.delete(objectToRemove)
}
}
}
}
func trackProgress(object: ProgressModel) { |
swift | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
} |
swift | XCTAssertEqual("".stp_safeSubstring(to: 0), "")
XCTAssertEqual("".stp_safeSubstring(to: 1), "")
}
func testSafeSubstringFromIndex() {
XCTAssertEqual("foo".stp_safeSubstring(from: 0), "foo")
XCTAssertEqual("foo".stp_safeSubstring(from: 1), "oo")
XCTAssertEqual("foo".stp_safeSubstring(from: 3), "")
XCTAssertEqual("".stp_safeSubstring(from: 0), "")
XCTAssertEqual("".stp_safeSubstring(from: 1), "")
} |
swift | //MARK:- 定义属性
var tag_name : String = ""
var icon_url : String = ""
//MARK:- 自定义构造函数
override init(){
}
init (dict :[String : Any]){
super.init()
setValuesForKeys(dict)
}
override func setValue(_ value: Any?, forUndefinedKey key: String) {
} |
swift | // ginlo
//
// Created by RBU on 01/06/16.
// Copyright © 2020 ginlo.net GmbH. All rights reserved.
//
import SIMSmeCore
import UIKit
|
swift | The type or discipline-style of the claim.
URL: http://hl7.org/fhir/claim-type-link
ValueSet: http://hl7.org/fhir/ValueSet/claim-type-link
*/
public enum ClaimType: String, FHIRPrimitiveType { |
swift | }
}
public protocol AddressesNodeServiceProtocol {
/**
Account's Waves balance |
swift | // NeuralNetwork
//
// Created by Igor Kotkovets on 10/26/19.
// Copyright © 2019 Igor Kotkovets. All rights reserved.
//
import Cocoa
import RxCocoa
import RxSwift
|
swift | import Foundation
struct Task {
var name: String
var servingGoals: Set<Goal>
}
|
swift | super.setUp()
window = UIWindow()
setup___VARIABLE_sceneName___ViewController()
}
override func tearDown() {
window = nil
super.tearDown()
}
|
swift | public func addSearchBar(placeHolder: String? = nil, noResultMessage: NSAttributedString? = nil) {
self.searchBarDelegate = RSSearchBarDelegate(placeHolder: placeHolder ?? mDefaultSearchPlaceHolder, message: noResultMessage) { [weak self] (searchString) in
self?.tableViewDataSourceDelegate.updateSearch(searchString)
}
self.tableHeaderView = self.searchBarDelegate?.searchBar
}
}
// MARK: - RSTableViewDataSourceUpdate
extension RSTableView: RSTableViewDataSourceUpdate {
/// new data updated in dataSource |
swift | if self.type != nil {try container.encode(self.type, forKey: .type)}
}
}
extension DataFactory {
public static func createEndpointServiceResultProtocol() -> EndpointServiceResultProtocol {
|
swift | }
private var descriptionLabel: [UILabel] {
localizeAndSplit(.local_authority_information_description).map { BaseLabel().styleAsBody().set(text: String($0)) }
}
var content: [UIView] {
var content = [title]
content.append(contentsOf: descriptionLabel)
return [stack(for: content, spacing: .halfSpacing)]
}
|
swift | import XCTest
class FirebaseSimpleTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown() |
swift |
import Foundation
import RxSwift
public protocol MovieServicable {
/**
Get a list of movies in theatres.
- Returns: Single<[Movie]>
*/ |
swift | }
extension APIClient {
typealias JSONTaskCompletionHandler = (Decodable?, APIError?) -> Void
func decodingTask<T: Decodable>(with request: URLRequest, decodingType: T.Type, completionHandler completion: @escaping JSONTaskCompletionHandler) -> URLSessionDataTask {
let task = session.dataTask(with: request) { data, response, error in
guard let httpResponse = response as? HTTPURLResponse else {
completion(nil, .requestFailed)
return
} |
swift | override var isSelected: Bool {
didSet {
self.backgroundColor = isOn ? #colorLiteral(red: 0.3058823529, green: 0.3058823529, blue: 0.3254901961, alpha: 1) : #colorLiteral(red: 0.2, green: 0.2, blue: 0.2, alpha: 1)
accessibilityValue = isOn ?
NSLocalizedString("On", comment: "On") :
NSLocalizedString("Off", comment: "Off")
}
}
var value: Double = 0.0 { |
swift | //
// Created by Pan on 2018/7/24.
// Copyright © 2018年 Youzan. All rights reserved.
//
import UIKit
class SwiftWebViewController: UIViewController {
private var webView = YZWebView(webViewType: .uiWebView)
var urlString = "https://h5.youzan.com/v2/goods/3ewlegud0qcjp"
|
swift | // RelatedVideoCellModel.swift
// Rx_TubeApp
//
// Created by 細田 大志 on 2017/11/18.
// Copyright © 2017 HIroshi Hosoda. All rights reserved.
//
final class RelatedVideoCellModel {
let publishedAt: String
let title: String
let thumbnailUrl: String
let channelTitle: String
init(video: SearchItemDetails.Video) { |
swift | return v
}
static func get<T: Any>(base: Any, key: UnsafePointer<UInt8>) -> T? {
return objc_getAssociatedObject(base, key) as? T
}
static func set<T: Any>(base: Any, key: UnsafePointer<UInt8>, value: T) {
objc_setAssociatedObject(base, key, value, .OBJC_ASSOCIATION_RETAIN)
}
}
|
swift | }
private func addQuantityLabel(){
quantityLabel = UILabel()
quantityLabel.textAlignment = .right
labelsContainer.addArrangedSubview(quantityLabel)
}
private func addConstraintsToLabelsContainer(){
let leading = NSLayoutConstraint(item: labelsContainer, attribute: .leading, relatedBy: .equal, toItem: self.contentView.safeAreaLayoutGuide, attribute: .leading, multiplier: 1, constant: 0)
let top = NSLayoutConstraint(item: labelsContainer, attribute: .top, relatedBy: .equal, toItem: self.contentView.safeAreaLayoutGuide, attribute: .top, multiplier: 1, constant: 0)
let trailing = NSLayoutConstraint(item: labelsContainer, attribute: .trailing, relatedBy: .equal, toItem: self.contentView.safeAreaLayoutGuide, attribute: .trailing, multiplier: 1, constant: 0)
let bottom = NSLayoutConstraint(item: labelsContainer, attribute: .bottom, relatedBy: .equal, toItem: self.contentView.safeAreaLayoutGuide, attribute: .bottom, multiplier: 1, constant: 0)
self.contentView.addConstraints([leading, top, trailing, bottom])
} |
swift |
for msg in postWait {
ws.writeString(fixDoubleUTF8(msg))
}
|
swift |
/// Lists all search domains owned by an account.
public func listDomainNames() -> Future<ListDomainNamesResponse> {
return client.send(operation: "ListDomainNames", path: "/", httpMethod: "POST")
} |
swift | }
}
/**
Draw a half transparent piece at the coordinate that the mouse is hovering over
*/
private func drawPendingPiece() {
if let co = pendingPieceCo {
if !isValid(co, dim) { return }
if pieces[co.row][co.col] == .none { // If the coordinate is not occupied
let rect = self.rect(at: co)
if board.curPlayer == .black {
blackWithAlpha?.draw(in: rect)
} else { |
swift | func makeCoordinator() -> Coordinator {
return Coordinator(selection: $selection)
}
class Coordinator: NSObject, MKMapViewDelegate {
@Binding var selection: MKAnnotation? |
swift | var style: CalendarStyle!
if currentStyle == .Dark {
currentStyle = .Light
title = "Dark"
style = StyleGenerator.defaultStyle()
} else {
title = "Light"
style = StyleGenerator.darkStyle()
currentStyle = .Dark
}
updateStyle(style)
navigationItem.rightBarButtonItem!.title = title
navigationController?.navigationBar.barTintColor = style.header.backgroundColor
navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:style.header.swipeLabel.textColor] |
swift |
override func onProvisionUsingQr() {
let qrCodeReaderVC = QrCodeReader(delegate: self)
self.navigationController?.pushViewController(qrCodeReaderVC, animated: true)
}
|
swift | .rotationEffect(Angle(degrees: 25))
.shadow(radius: Constants.radiusStandard)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing)
.padding(.vertical, -5)
.padding(.horizontal, -20)
.mask(RoundedRectangle(cornerRadius: 5))
}
}
} |
swift | function(self,cell as! FSPagerViewCell,index)
}
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
if !self.isPossiblyRotating && self.numberOfItems > 0 {
// In case someone is using KVO
let currentIndex = lround(Double(self.scrollOffset)) % self.numberOfItems
if (currentIndex != self.currentIndex) {
self.currentIndex = currentIndex
}
}
guard let function = self.delegate?.pagerViewDidScroll else {
return
} |
swift | func presentData(response: Feed.Model.Response.ResponseType) {
switch response {
case .presentFeed(result: let result):
switch result { |
swift | func buildKeyboard() -> Keyboard {
let keyboard = defaultKeyboard()
let defaults = UserDefaults.standard
for language in Languages.getLanguages() { |
swift | import Cocoa
class FruitPasteboardWriter: NSObject, NSPasteboardWriting {
var fruit: String
var index: Int
init(fruit: String, at index: Int) {
self.fruit = fruit
self.index = index
}
func writableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] {
return [.string, .tableViewIndex]
} |
swift | func printTaskLocal<V>(
_ key: TaskLocal<V>,
_ expected: V? = nil,
file: String = #file, line: UInt = #line
) -> V? {
let value = key.get()
print("\(key) (\(value)) at \(file):\(line)")
if let expected = expected {
assert("\(expected)" == "\(value)",
"Expected [\(expected)] but found: \(value), at \(file):\(line)")
}
return expected
}
|
swift | arguments: [Any?] = []
) throws
{
self.database = database
self.sql = sql
self.arguments = arguments
self.currentRow = -1
self.statement = try PreparedStatement(database: database, sql: sql, arguments: arguments)
} |
swift |
AppEnvironment.pushEnvironment(mainBundle: Bundle.framework)
UIView.setAnimationsEnabled(false)
}
|
swift | Line(x1: 15, y1: 9, x2: 9, y2: 15),
Line(x1: 9, y1: 9, x2: 15, y2: 15),
])
}
} |