Convert to Swift 4.2

This commit is contained in:
Eryn Wells 2018-10-05 13:38:32 -07:00
parent c2633b5174
commit 9f5b7c7cb5
4 changed files with 28 additions and 20 deletions

View file

@ -358,18 +358,20 @@
C0BBE3661F2E816500E68524 = {
CreatedOnToolsVersion = 8.3.3;
DevelopmentTeam = 78372RE6B4;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
C0BBE3771F2E816500E68524 = {
CreatedOnToolsVersion = 8.3.3;
DevelopmentTeam = 78372RE6B4;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
TestTargetID = C0BBE3661F2E816500E68524;
};
C0BBE38B1F2E81B600E68524 = {
CreatedOnToolsVersion = 8.3.3;
DevelopmentTeam = 78372RE6B4;
LastSwiftMigration = 0830;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
C0BBE3931F2E81B600E68524 = {
@ -659,7 +661,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.erynwells.Metaballs;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
@ -673,7 +676,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.erynwells.Metaballs;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};
@ -688,7 +692,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.erynwells.MetaballsTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Metaballs.app/Contents/MacOS/Metaballs";
};
name = Debug;
@ -704,7 +709,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.erynwells.MetaballsTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Metaballs.app/Contents/MacOS/Metaballs";
};
name = Release;
@ -730,7 +736,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
@ -756,7 +763,8 @@
PRODUCT_BUNDLE_IDENTIFIER = me.erynwells.MetaballsKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};

View file

@ -35,7 +35,7 @@ class ViewController: NSViewController, RendererDelegate {
return self.view as! MTKView
}
override init?(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
let params = ViewController.defaultParameters()
field = Field(parameters: params)
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)

View file

@ -113,9 +113,9 @@ public class PreferencesViewController: NSViewController {
view.addSubview(colorStackView)
let centerX = colorStackView.centerXAnchor.constraint(equalTo: view.centerXAnchor)
centerX.priority = 999
centerX.priority = NSLayoutConstraint.Priority(rawValue: 999)
let centerY = colorStackView.centerYAnchor.constraint(equalTo: view.centerYAnchor)
centerY.priority = 999
centerY.priority = NSLayoutConstraint.Priority(rawValue: 999)
NSLayoutConstraint.activate([
centerX, centerY,
colorStackView.topAnchor.constraint(greaterThanOrEqualTo: view.topAnchor, constant: 8),
@ -153,7 +153,7 @@ public class PreferencesViewController: NSViewController {
override public func viewWillDisappear() {
super.viewWillDisappear()
NSColorPanel.shared().close()
NSColorPanel.shared.close()
}
private func prepareColorViews() {
@ -166,7 +166,7 @@ public class PreferencesViewController: NSViewController {
}
private func prepareColorPanel() {
let colorPanel = NSColorPanel.shared()
let colorPanel = NSColorPanel.shared
colorPanel.isContinuous = true
colorPanel.setTarget(self)
colorPanel.setAction(#selector(PreferencesViewController.colorPanelDidUpdateValue))
@ -182,20 +182,20 @@ public class PreferencesViewController: NSViewController {
// MARK: - Actions
func colorPanelDidUpdateValue(_ colorPanel: NSColorPanel) {
@objc func colorPanelDidUpdateValue(_ colorPanel: NSColorPanel) {
postColorNotification()
}
func styleDidUpdate(sender: NSMenuItem) {
@objc func styleDidUpdate(sender: NSMenuItem) {
updateColorViewVisibility()
postColorNotification()
}
func sliderDidUpdate(sender: NSSlider) {
@objc func sliderDidUpdate(sender: NSSlider) {
postColorNotification()
}
func closeWindow() {
@objc func closeWindow() {
self.view.window?.close()
}
@ -260,7 +260,7 @@ class ParameterView: NSView {
stackView.addArrangedSubview(label)
control.translatesAutoresizingMaskIntoConstraints = false
control.setContentHuggingPriority(251, for: .horizontal)
control.setContentHuggingPriority(NSLayoutConstraint.Priority(rawValue: 251), for: .horizontal)
stackView.addArrangedSubview(control)
addSubview(stackView)

View file

@ -117,9 +117,9 @@ public class Renderer: NSObject, MTKViewDelegate {
encoder.label = "Render Pass"
encoder.setViewport(MTLViewport(originX: 0.0, originY: 0.0, width: Double(view.drawableSize.width), height: Double(view.drawableSize.height), znear: -1.0, zfar: 1.0))
encoder.setRenderPipelineState(renderPipelineState)
encoder.setVertexBytes(points, length: points.count * MemoryLayout<Vertex>.stride, at: 0)
encoder.setFragmentBuffer(field.parametersBuffer, offset: 0, at: 0)
encoder.setFragmentBuffer(field.ballBuffer, offset: 0, at: 1)
encoder.setVertexBytes(points, length: points.count * MemoryLayout<Vertex>.stride, index: 0)
encoder.setFragmentBuffer(field.parametersBuffer, offset: 0, index: 0)
encoder.setFragmentBuffer(field.ballBuffer, offset: 0, index: 1)
encoder.drawPrimitives(type: .triangle, vertexStart: 0, vertexCount: 6)
encoder.endEncoding()