import coremltools
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-5bf9ddba4efd> in <module>
----> 1 import coremltools
extension Optional { | |
func expect(_ message: String) -> Wrapped { | |
guard let value = self else { | |
preconditionFailure(message) | |
} | |
return value | |
} | |
} |
extension Result { | |
func expect(_ message: String) -> Success { | |
switch self { | |
case let .success(value): | |
return value | |
case let .failure(error): | |
preconditionFailure("\(message): \(error.localizedDescription)") | |
} | |
} |
import Logging | |
LoggingSystem.bootstrap { label in | |
var handler = PlaygroundHandler(label: label) | |
handler.logLevel = .trace | |
return handler | |
} | |
let logger = Logger(label: "hoge") |
import Darwin | |
func getVMStatistics64() -> vm_statistics64? { | |
let hostPort = mach_host_self() | |
var hostSize = mach_msg_type_number_t(MemoryLayout<vm_statistics64_data_t>.size / MemoryLayout<integer_t>.size) | |
var vmstat = vm_statistics64() | |
let result = withUnsafeMutablePointer(to: &vmstat) { | |
$0.withMemoryRebound(to: integer_t.self, capacity: Int(hostSize)) { | |
host_statistics64( | |
hostPort, |
import coremltools
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-5bf9ddba4efd> in <module>
----> 1 import coremltools
import Foundation | |
import AVFoundation | |
Bundle(path: "/System/Library/Frameworks/ShazamKit.framework")!.load() | |
class SHSession { | |
static let rawType = NSClassFromString("SHSession") as! NSObject.Type | |
let rawValue: NSObject | |
var delegate: SHSessionDelegate? { |
// Swift Playgrounds での利用例 | |
import PlaygroundSupport | |
import SwiftUI | |
struct ContentView { | |
@State var toastDuration: DispatchTimeInterval? | |
@State var toastMessage: LocalizedStringKey = "" | |
} |
import PhotosUI | |
import PlaygroundSupport | |
import SwiftUI | |
struct LivePhotoView: View { | |
let livePhoto: PHLivePhoto | |
var body: some View { | |
_LivePhotoView(livePhoto: livePhoto) | |
.aspectRatio( |
@propertyWrapper | |
public struct Box<Value> { | |
private var object: BoxObject<Value> | |
public var value: Value { | |
get { self.object.value } | |
set { | |
if !isKnownUniquelyReferenced(&self.object) { | |
self.object = self.object.copy() | |
} |
import PlaygroundSupport | |
import SwiftUI | |
struct ContentView: View { | |
@State var selection = 0 | |
var body: some View { | |
HStack { | |
Button { | |
self.selection = 0 |