Commit 72ba5767 authored by Aral Balkan's avatar Aral Balkan

Refactored for Xcode 6.3 Beta 2.

parent 019a6dee
......@@ -31,7 +31,6 @@
A75AABCC1A5ECFB000B105BA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A75AABCB1A5ECFB000B105BA /* ViewController.swift */; };
A75AABDD1A5ECFB000B105BA /* HeartbeatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A75AABDC1A5ECFB000B105BA /* HeartbeatTests.swift */; };
A760C9901A75A51100E84890 /* IndieNameFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A760C98F1A75A51100E84890 /* IndieNameFormatter.swift */; };
A77D76D91A990DB700F74F00 /* VMXMLParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = A77D76D81A990DB700F74F00 /* VMXMLParser.swift */; };
A77D76DD1A991F8300F74F00 /* balloon_512x512@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A77D76DC1A991F8300F74F00 /* balloon_512x512@2x.png */; };
A77D76DF1A99207600F74F00 /* TransparentWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A77D76DE1A99207600F74F00 /* TransparentWindow.swift */; };
A77D76E11A99208200F74F00 /* MainWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A77D76E01A99208200F74F00 /* MainWindow.swift */; };
......@@ -131,7 +130,6 @@
A75AABDB1A5ECFB000B105BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A75AABDC1A5ECFB000B105BA /* HeartbeatTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeartbeatTests.swift; sourceTree = "<group>"; };
A760C98F1A75A51100E84890 /* IndieNameFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IndieNameFormatter.swift; sourceTree = "<group>"; };
A77D76D81A990DB700F74F00 /* VMXMLParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VMXMLParser.swift; sourceTree = "<group>"; };
A77D76DC1A991F8300F74F00 /* balloon_512x512@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "balloon_512x512@2x.png"; sourceTree = "<group>"; };
A77D76DE1A99207600F74F00 /* TransparentWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransparentWindow.swift; sourceTree = "<group>"; };
A77D76E01A99208200F74F00 /* MainWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainWindow.swift; sourceTree = "<group>"; };
......@@ -371,14 +369,6 @@
name = Playgrounds;
sourceTree = "<group>";
};
A77D76D71A990D9600F74F00 /* github.com/varshylmobile/VMXMLParser */ = {
isa = PBXGroup;
children = (
A77D76D81A990DB700F74F00 /* VMXMLParser.swift */,
);
name = github.com/varshylmobile/VMXMLParser;
sourceTree = "<group>";
};
A77D76E21A9920FB00F74F00 /* Preloader and main windows */ = {
isa = PBXGroup;
children = (
......@@ -418,7 +408,6 @@
isa = PBXGroup;
children = (
A77D76E71A9922B000F74F00 /* ADBToolKit */,
A77D76D71A990D9600F74F00 /* github.com/varshylmobile/VMXMLParser */,
A7CC20061A6C992F00B49AA9 /* SwiftyJSON.swift */,
A74C9EEE1A6688D30083B288 /* Websocket.swift */,
A79C8B931A8CDEF600F1948A /* source.ind.ie */,
......@@ -736,7 +725,6 @@
A74CC6611A668A7B0083B288 /* Helpers.swift in Sources */,
A7E7D7BA1A616B1E003501C1 /* ContentViewController.swift in Sources */,
A7CC20071A6C992F00B49AA9 /* SwiftyJSON.swift in Sources */,
A77D76D91A990DB700F74F00 /* VMXMLParser.swift in Sources */,
A75AABCC1A5ECFB000B105BA /* ViewController.swift in Sources */,
A78DAE7C1A7FCA60009FDB15 /* NoodleCustomImageRep.m in Sources */,
A7E7D7B51A616B0B003501C1 /* IndieSplitView.swift in Sources */,
......
......@@ -60,7 +60,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NodeDelegate {
{
println("Preloader window is going away… showing main one.")
let storyboard = NSStoryboard(name: "Main", bundle: NSBundle.mainBundle())
mainWindowController = storyboard!.instantiateControllerWithIdentifier("mainWindowController") as NSWindowController
mainWindowController = storyboard!.instantiateControllerWithIdentifier("mainWindowController") as! NSWindowController
mainWindowController.showWindow(self)
mainWindowController.window?.makeKeyAndOrderFront(self)
}
......
......@@ -47,8 +47,8 @@ class ContentViewController: NSViewController {
//
self.webkit.translatesAutoresizingMaskIntoConstraints = false
let viewsDictionary:NSDictionary = ["webkit": self.webkit]
let horizontalConstraints:[AnyObject]! = NSLayoutConstraint.constraintsWithVisualFormat("H:|-0-[webkit]-0-|", options: nil, metrics: nil, views: viewsDictionary)
let verticalConstraints:[AnyObject]! = NSLayoutConstraint.constraintsWithVisualFormat("V:|-0-[webkit]-0-|", options: nil, metrics: nil, views: viewsDictionary)
let horizontalConstraints:[AnyObject]! = NSLayoutConstraint.constraintsWithVisualFormat("H:|-0-[webkit]-0-|", options: nil, metrics: nil, views: viewsDictionary as [NSObject : AnyObject])
let verticalConstraints:[AnyObject]! = NSLayoutConstraint.constraintsWithVisualFormat("V:|-0-[webkit]-0-|", options: nil, metrics: nil, views: viewsDictionary as [NSObject : AnyObject])
self.view.addConstraints(horizontalConstraints)
self.view.addConstraints(verticalConstraints)
......
......@@ -49,7 +49,7 @@ class HeartbeatMainWindowController: NSWindowController {
let animation:CATransition = CATransition()
animation.type = kCATransitionFade
if let layer = self.window?.contentView.layer?
if let window = self.window, doubleWrappedOptionalWTF = window.contentView.layer, layer = doubleWrappedOptionalWTF
{
layer.addAnimation(animation, forKey: "layerAnimation")
shade.removeFromSuperview()
......@@ -65,7 +65,7 @@ class HeartbeatMainWindowController: NSWindowController {
if let window = self.window
{
if let layer = window.contentView.layer?
if let doubleWrappedOptionalWTF = window.contentView.layer, layer = doubleWrappedOptionalWTF
{
layer.addAnimation(animation, forKey: "layerAnimation")
......
......@@ -120,7 +120,7 @@ extension String {
func replaceCharactersInRange(range:Range<Int>, withString: String!) -> String {
var result:NSMutableString = NSMutableString(string: self)
result.replaceCharactersInRange(NSRange(range), withString: withString)
return result
return result as String
}
}
......@@ -141,10 +141,10 @@ extension String {
}
// set starting point for search based on the finding of the first character
i = distance(self.startIndex, startInd)
while i<=countElements(self)-countElements(findStr) {
if self[advance(self.startIndex, i)..<advance(self.startIndex, i+countElements(findStr))] == findStr {
arr.append(Range(start:advance(self.startIndex, i),end:advance(self.startIndex, i+countElements(findStr))))
i = i+countElements(findStr)
while i<=count(self)-count(findStr) {
if self[advance(self.startIndex, i)..<advance(self.startIndex, i+count(findStr))] == findStr {
arr.append(Range(start:advance(self.startIndex, i),end:advance(self.startIndex, i+count(findStr))))
i = i+count(findStr)
}
i++
}
......
......@@ -42,8 +42,8 @@ class HorizontalSplitViewController: NSSplitViewController {
self.debugPanelIsCollapsed = !self.debugPanelIsCollapsed
// Set the holding priorities so that the panels are rigid and cause the window size to change.
var firstPanel: NSSplitViewItem = self.splitViewItems[0] as NSSplitViewItem
var secondPanel: NSSplitViewItem = self.splitViewItems[1] as NSSplitViewItem
var firstPanel: NSSplitViewItem = self.splitViewItems[0] as! NSSplitViewItem
var secondPanel: NSSplitViewItem = self.splitViewItems[1] as! NSSplitViewItem
firstPanel.holdingPriority = 1.0
secondPanel.holdingPriority = 1000.0
......
......@@ -68,7 +68,7 @@ class IndieNameFormatter: NSFormatter {
override func isPartialStringValid(partialString: String, newEditingString newString: AutoreleasingUnsafeMutablePointer<NSString?>, errorDescription error: AutoreleasingUnsafeMutablePointer<NSString?>) -> Bool {
// Create set of acceptable characters, starting with alpha-numeric ones.
var acceptableCharactersSet:NSMutableCharacterSet = NSCharacterSet.alphanumericCharacterSet().mutableCopy() as NSMutableCharacterSet
var acceptableCharactersSet:NSMutableCharacterSet = NSCharacterSet.alphanumericCharacterSet().mutableCopy() as! NSMutableCharacterSet
// Add whitespace characters (whitespace is not allowed in Ind.ie names
// but we will automatically convert them into dashes when presenting the
......@@ -80,7 +80,7 @@ class IndieNameFormatter: NSFormatter {
acceptableCharactersSet.formUnionWithCharacterSet(NSCharacterSet(charactersInString: "-"))
// Make a set of unacceptable characters by inverting the acceptable ones.
var unacceptableCharactersSet:NSMutableCharacterSet = acceptableCharactersSet.mutableCopy() as NSMutableCharacterSet
var unacceptableCharactersSet:NSMutableCharacterSet = acceptableCharactersSet.mutableCopy() as! NSMutableCharacterSet
unacceptableCharactersSet.invert()
var acceptableString:String = (partialString.componentsSeparatedByCharactersInSet(unacceptableCharactersSet) as NSArray).componentsJoinedByString("")
......@@ -149,7 +149,7 @@ class IndieNameFormatter: NSFormatter {
massagedIndieName = massagedIndieName.stringByReplacingOccurrencesOfString(" ", withString: "-", options: NSStringCompareOptions.allZeros, range: nil)
// 4. Remove redundant hyphens.
massagedIndieName = collapseHyphensRegularExpression.stringByReplacingMatchesInString(massagedIndieName, options: NSMatchingOptions.allZeros, range: NSMakeRange(0, countElements(massagedIndieName)), withTemplate: "-")
massagedIndieName = collapseHyphensRegularExpression.stringByReplacingMatchesInString(massagedIndieName, options: NSMatchingOptions.allZeros, range: NSMakeRange(0, count(massagedIndieName)), withTemplate: "-")
//
// 5. Limit to a strict character set of a-z, 0-9, and - (hyphen)
......@@ -162,7 +162,7 @@ class IndieNameFormatter: NSFormatter {
massagedIndieName = "".join(massagedIndieName.componentsSeparatedByCharactersInSet(strictCharacterSet))
// 6. Impose the character count limit
if countElements(massagedIndieName) > maximumIndieNameLength {
if count(massagedIndieName) > maximumIndieNameLength {
let maximumAllowableLengthIndex:String.Index = advance(massagedIndieName.startIndex, maximumIndieNameLength)
massagedIndieName = massagedIndieName.substringToIndex(maximumAllowableLengthIndex)
}
......@@ -185,7 +185,7 @@ class IndieNameFormatter: NSFormatter {
// println("getObjectValue: \(string)")
// With thanks to: http://stackoverflow.com/a/27868984/253485
let stringToReturn:String = string.copy() as String
let stringToReturn:String = string.copy() as! String
obj.memory = stringToReturn
return true
}
......
......@@ -26,8 +26,8 @@ class IndieSplitViewController: NSSplitViewController {
if let storyboard = self.storyboard
{
let mainNavigationViewController:NSViewController = storyboard.instantiateControllerWithIdentifier("mainNavigation") as NSViewController
let conversationsViewController:ConversationsViewController = storyboard.instantiateControllerWithIdentifier("conversations") as ConversationsViewController
let mainNavigationViewController:NSViewController = storyboard.instantiateControllerWithIdentifier("mainNavigation") as! NSViewController
let conversationsViewController:ConversationsViewController = storyboard.instantiateControllerWithIdentifier("conversations") as! ConversationsViewController
let mainNavigationSplitViewItem = NSSplitViewItem(viewController: mainNavigationViewController)
let conversationsSplitViewItem = NSSplitViewItem(viewController: conversationsViewController)
......@@ -45,7 +45,7 @@ class IndieSplitViewController: NSSplitViewController {
{
// Setup is complete, load the main interface.
println("Setup is complete, loading the main interface.")
let mainInterfaceViewController:NSViewController = storyboard.instantiateControllerWithIdentifier("mainInterface") as NSViewController
let mainInterfaceViewController:NSViewController = storyboard.instantiateControllerWithIdentifier("mainInterface") as! NSViewController
mainSplitViewItem = NSSplitViewItem(viewController: mainInterfaceViewController)
mainNavigationSplitViewItem.collapsed = false
......@@ -55,7 +55,7 @@ class IndieSplitViewController: NSSplitViewController {
{
// Setup not complete, load the setup process.
println("Setup is *not* complete, loading the setup process.")
let setupProcessViewController:ContentViewController = storyboard.instantiateControllerWithIdentifier("setupProcess") as ContentViewController
let setupProcessViewController:ContentViewController = storyboard.instantiateControllerWithIdentifier("setupProcess") as! ContentViewController
mainSplitViewItem = NSSplitViewItem(viewController: setupProcessViewController)
mainNavigationSplitViewItem.collapsed = true
......@@ -68,7 +68,7 @@ class IndieSplitViewController: NSSplitViewController {
// DEBUG
println("IndieSplitViewController: splitViewItems:")
for splitViewItem in self.splitViewItems {
let splitViewItem = splitViewItem as NSSplitViewItem
let splitViewItem = splitViewItem as! NSSplitViewItem
println("\(splitViewItem.viewController.title)")
}
......@@ -113,9 +113,9 @@ class IndieSplitViewController: NSSplitViewController {
// Anchor the window
//self.view.window?.setAnchorAttribute(.Leading, forOrientation: .Horizontal)
var firstPanel: NSSplitViewItem = self.splitViewItems[0] as NSSplitViewItem
var secondPanel: NSSplitViewItem = self.splitViewItems[1] as NSSplitViewItem
var thirdPanel: NSSplitViewItem = self.splitViewItems[2] as NSSplitViewItem
var firstPanel: NSSplitViewItem = self.splitViewItems[0] as! NSSplitViewItem
var secondPanel: NSSplitViewItem = self.splitViewItems[1] as! NSSplitViewItem
var thirdPanel: NSSplitViewItem = self.splitViewItems[2] as! NSSplitViewItem
// var currentFirstPanelHoldingPriority = firstPanel.holdingPriority
// var currentSecondPanelHoldingPriority = secondPanel.holdingPriority
......
......@@ -64,10 +64,10 @@ extension NSImage
func data(ofType fileType:NSBitmapImageFileType, dpi:UInt, properties: [NSObject:AnyObject]?) -> NSData?
{
let resolutionScaleFactor:UInt = dpi/72
let exportWidthInPixels:UInt = UInt(self.size.width) * resolutionScaleFactor
let exportHeightInPixels:UInt = UInt(self.size.height) * resolutionScaleFactor
let colorSpace:CGColorSpaceRef = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB)
let resolutionScaleFactor:Int = Int(dpi/72)
let exportWidthInPixels:Int = Int(self.size.width) * resolutionScaleFactor
let exportHeightInPixels:Int = Int(self.size.height) * resolutionScaleFactor
let colorSpace:CGColorSpace! = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB)
let bitmapInfo:CGBitmapInfo = .ByteOrderDefault | CGBitmapInfo(CGImageAlphaInfo.PremultipliedLast.rawValue)
let originalSize:NSSize = self.size
......@@ -76,7 +76,8 @@ extension NSImage
self.size = newSize
// Create a graphics context at the exact pixel dimensions that we want the image file data at.
let cgContext:CGContextRef = CGBitmapContextCreate(nil, exportWidthInPixels, exportHeightInPixels, 8, 4 * exportWidthInPixels, colorSpace, bitmapInfo)
let cgContext:CGContext = CGBitmapContextCreate(nil, exportWidthInPixels, exportHeightInPixels, 8, 4 * exportWidthInPixels, colorSpace, bitmapInfo)
let nsGraphicsContext:NSGraphicsContext = NSGraphicsContext(CGContext: cgContext, flipped: false)
let cgImage:CGImage? = (self.CGImageForProposedRect(nil, context: nsGraphicsContext, hints: nil))?.takeUnretainedValue()
......
......@@ -217,7 +217,7 @@ public class Node: NSObject, WebSocketDelegate
text = text.substringFromIndex(rangeToCut.location+2)
}
text = "\t" + text //+ "\n"
text = "\t" + (text as! String) //+ "\n"
println("📡 💻 \(text)")
}
}
......@@ -282,12 +282,12 @@ public class Node: NSObject, WebSocketDelegate
// Retrieve the function by ID
//
let remoteFunctionCallback = remoteFunctionResponseCallbacks[id]! as Callback
let remoteFunctionDetails:[String:AnyObject] = remoteFunctionCallRequests[id]! as [String:AnyObject]
let remoteFunctionDetails:[String:AnyObject] = remoteFunctionCallRequests[id]! as! [String:AnyObject]
let response:JSON = json["response"]
println("RESPONSE: \(response)")
let durationOfCall = NSDate().timeIntervalSinceDate(remoteFunctionDetails["timestamp"] as NSDate)
let durationOfCall = NSDate().timeIntervalSinceDate(remoteFunctionDetails["timestamp"] as! NSDate)
println("[[[[[[ CALL TOOK \(durationOfCall) seconds ]]]]]")
......
......@@ -44,27 +44,20 @@ class ProfileImageComponentControlPanelViewController: NSViewController {
//
override convenience init() {
self.init(.Default)
}
required convenience init(coder aDecoder: NSCoder) {
self.init(.Coder(aDecoder))
}
// Common initialiser.
private init(_ initMethod:InitMethod) {
override init()
{
images = ["laura-and-osky.jpg", "aral-balkan-by-christina-von-poser.png", "burger.jpg", "laura.jpg", "aral-100-100.jpg"]
switch initMethod {
case .Default:
super.init()
case let .Coder(coder):
super.init(coder: coder)
}
super.init()
}
required init?(coder: NSCoder)
{
images = ["laura-and-osky.jpg", "aral-balkan-by-christina-von-poser.png", "burger.jpg", "laura.jpg", "aral-100-100.jpg"]
super.init(coder: coder)
}
//
// MARK: - View lifecycle
......@@ -90,7 +83,7 @@ class ProfileImageComponentControlPanelViewController: NSViewController {
func profileImageSnapshotReady(notification:NSNotification) {
println("Profile Image Component Control Panel: snapshot received notification arrived.")
if let info:Dictionary = notification.userInfo {
let snapshot:NSImage = info["image"] as NSImage
let snapshot:NSImage = info["image"] as! NSImage
self.secondImageView.image = snapshot
// Mask it.
......@@ -108,11 +101,11 @@ class ProfileImageComponentControlPanelViewController: NSViewController {
println("Profile Image Component Control Panel: bounds change notification received.")
if let userInfo:Dictionary = notification.userInfo
{
let scrollPositionX = Double(userInfo["scrollPositionX"] as CGFloat)
let scrollPositionY = Double(userInfo["scrollPositionY"] as CGFloat)
let scaledImageWidthBeforeMasking = Double(userInfo["scaledImageWidthBeforeMasking"] as CGFloat)
let scaledImageHeightBeforeMasking = Double(userInfo["scaledImageHeightBeforeMasking"] as CGFloat)
let zoomFactor = Double(userInfo["zoomFactor"] as CGFloat)
let scrollPositionX = Double(userInfo["scrollPositionX"] as! CGFloat)
let scrollPositionY = Double(userInfo["scrollPositionY"] as! CGFloat)
let scaledImageWidthBeforeMasking = Double(userInfo["scaledImageWidthBeforeMasking"] as! CGFloat)
let scaledImageHeightBeforeMasking = Double(userInfo["scaledImageHeightBeforeMasking"] as! CGFloat)
let zoomFactor = Double(userInfo["zoomFactor"] as! CGFloat)
self.scrollPositionX.doubleValue = scrollPositionX
self.scrollPositionY.doubleValue = scrollPositionY
......
......@@ -107,29 +107,24 @@ class ProfileImageComponentViewController: NSViewController, NSComboBoxDataSourc
}
//
// MARK: - Override the initialisers gracefully.
// MARK: - Override the initialisers.
//
override convenience init() {
self.init(.Default)
}
required convenience init(coder aDecoder: NSCoder) {
self.init(.Coder(aDecoder))
}
private init(_ initMethod:InitMethod) {
override init() {
faces = []
super.init()
}
required init?(coder: NSCoder) {
faces = []
switch initMethod {
case .Default:
super.init()
case let .Coder(coder):
super.init(coder: coder)
}
super.init(coder: coder)
}
// MARK: - View lifecycle
override func viewDidLoad() {
......@@ -186,12 +181,12 @@ class ProfileImageComponentViewController: NSViewController, NSComboBoxDataSourc
CIDetectorAccuracy: CIDetectorAccuracyHigh,
CIDetectorSmile:true
]
let detector:CIDetector = CIDetector(ofType: CIDetectorTypeFace, context: context, options: coreImageDetectorOptions)
let detector:CIDetector = CIDetector(ofType: CIDetectorTypeFace, context: context, options: coreImageDetectorOptions as [NSObject : AnyObject])
let ciImage = CIImage(CGImage:cgImage)
var features = detector.featuresInImage(ciImage)
self.faces = features as [CIFaceFeature]
self.faces = features as! [CIFaceFeature]
println("Features: \(features)")
......@@ -255,7 +250,7 @@ class ProfileImageComponentViewController: NSViewController, NSComboBoxDataSourc
}
}
} as NoodleCustomImageRep
} as! NoodleCustomImageRep
imageRepresentation.size = size
println("Size: \(size)")
......@@ -275,7 +270,7 @@ class ProfileImageComponentViewController: NSViewController, NSComboBoxDataSourc
// With huge thanks to http://www.panic.com/blog/fun-with-face-recognition/
image.lockFocus()
for face:CIFaceFeature in features as [CIFaceFeature]! {
for face:CIFaceFeature in features as! [CIFaceFeature]! {
var bounds = face.bounds
NSColor(calibratedWhite: 1.0, alpha: 1.0).set()
......@@ -559,7 +554,7 @@ class ProfileImageComponentViewController: NSViewController, NSComboBoxDataSourc
userInfo["zoomFactor"] = self.imageView.zoomFactor
// Post a notification (mainly for the benefit of the control panel for debugging).
NSNotificationCenter.defaultCenter().send(ProfileImageComponentNotification.named(.ProfileImageBoundsDidChange), from: self, with: userInfo)
NSNotificationCenter.defaultCenter().send(ProfileImageComponentNotification.named(.ProfileImageBoundsDidChange), from: self, with: userInfo as [NSObject : AnyObject])
}
//
......
......@@ -25,7 +25,7 @@ class SetupHandleTextField: NSTextField
println("ACCESS:::: \(attribute) - \(parameter)")
var attributedStringToReturn:NSAttributedString
attributedStringToReturn = (attribute == (NSAccessibilityAttributedStringForRangeParameterizedAttribute as String)) ? NSAttributedString(string: "Enter the handle you want to use on Indie") : (super.accessibilityAttributeValue(attribute, forParameter: parameter) as NSAttributedString)
attributedStringToReturn = (attribute == (NSAccessibilityAttributedStringForRangeParameterizedAttribute as String)) ? NSAttributedString(string: "Enter the handle you want to use on Indie") : (super.accessibilityAttributeValue(attribute, forParameter: parameter) as! NSAttributedString)
return attributedStringToReturn
......
......@@ -61,7 +61,7 @@ class SetupMessageViewController: NSViewController
}
else
{
self.messageLabel.stringValue = matches[1] as String
self.messageLabel.stringValue = matches[1] as! String
self.accessibilityHint = matches[2] as? String
}
}
......
......@@ -14,27 +14,24 @@ class SetupView: NSVisualEffectView {
// MARK: - Override the initialisers gracefully.
//
override convenience init() {
self.init(.Default)
}
required convenience init(coder aDecoder: NSCoder) {
self.init(.Coder(aDecoder))
override init() {
super.init()
// Common setup
self.setAccessibilityRole(NSAccessibilityGroupRole)
}
private init(_ initMethod:InitMethod) {
switch initMethod {
case .Default:
super.init()
case let .Coder(coder):
super.init(coder: coder)
}
required init?(coder: NSCoder)
{
super.init(coder: coder)
// Common setup
self.setAccessibilityRole(NSAccessibilityGroupRole)
}
override func accessibilityIsIgnored() -> Bool {
override func accessibilityIsIgnored() -> Bool
{
return false
}
}
......@@ -67,7 +67,7 @@ class SetupViewController: NSViewController, SetupDelegate {
for index in 1...2
{
var tempViewController:SetupStepViewController = self.storyboard!.instantiateControllerWithIdentifier("Step\(index)") as SetupStepViewController
var tempViewController:SetupStepViewController = self.storyboard!.instantiateControllerWithIdentifier("Step\(index)") as! SetupStepViewController
tempViewController.delegate = self
viewControllers.append(tempViewController)
}
......@@ -101,10 +101,10 @@ class SetupViewController: NSViewController, SetupDelegate {
switch(segueIdentifier)
{
case "embedSetupProgressIndicator":
self.progressIndicator = segue.destinationController as SetupProgressIndicatorViewController
self.progressIndicator = segue.destinationController as! SetupProgressIndicatorViewController
case "embedSetupMessageViewController":
self.message = segue.destinationController as SetupMessageViewController
self.message = segue.destinationController as! SetupMessageViewController
// Ignore manual (non-embedded segue used during the pre-release programme).
case "prereleaseMessage":
......
......@@ -130,11 +130,11 @@ class StepOneViewController: SetupStepViewController
if nameText.hasSuffix("-")
{
nameText = nameText.substringToIndex(countElements(nameText)-1)
nameText = nameText.substringToIndex(count(nameText)-1)
nameTextField.stringValue = nameText
}
if countElements(nameText) > 0
if count(nameText) > 0
{
// Show progress
self.delegate?.showProgress(NSLocalizedString("Checking if account exists…", comment:"Progress indicator text"))
......
......@@ -141,7 +141,7 @@ class StepTwoViewController: SetupStepViewController
if let segueIdentifier = segue.identifier {
switch(segueIdentifier) {
case "embedProfileImageComponent":
self.profileImageComponent = segue.destinationController as ProfileImageComponentViewController
self.profileImageComponent = segue.destinationController as! ProfileImageComponentViewController
default:
fatalError("Unexpected container view embedded in view: \(segueIdentifier)")
......
......@@ -139,9 +139,9 @@ extension JSON: SequenceType{
get {
switch self.type {
case .Array:
return (self.object as [AnyObject]).isEmpty
return (self.object as! [AnyObject]).isEmpty
case .Dictionary:
return (self.object as [String : AnyObject]).isEmpty
return (self.object as! [String : AnyObject]).isEmpty
default:
return false
}
......@@ -170,7 +170,7 @@ extension JSON: SequenceType{
public func generate() -> GeneratorOf <(String, JSON)> {
switch self.type {
case .Array:
let array_ = object as [AnyObject]
let array_ = object as! [AnyObject]
var generate_ = array_.generate()
var index_: Int = 0
return GeneratorOf<(String, JSON)> {
......@@ -181,7 +181,7 @@ extension JSON: SequenceType{
}
}
case .Dictionary:
let dictionary_ = object as [String : AnyObject]
let dictionary_ = object as! [String : AnyObject]
var generate_ = dictionary_.generate()
return GeneratorOf<(String, JSON)> {
if let (key_: String, value_: AnyObject) = generate_.next() {
......@@ -221,7 +221,7 @@ extension JSON {
return errorResult_
}
let array_ = self.object as [AnyObject]
let array_ = self.object as! [AnyObject]
if index >= 0 && index < array_.count {
return JSON(array_[index])
......@@ -233,7 +233,7 @@ extension JSON {
}
set {
if self.type == .Array {
var array_ = self.object as [AnyObject]
var array_ = self.object as! [AnyObject]
if array_.count > index {
array_[index] = newValue.object
self.object = array_
......@@ -259,7 +259,7 @@ extension JSON {
}
set {
if self.type == .Dictionary {
var dictionary_ = self.object as [String : AnyObject]
var dictionary_ = self.object as! [String : AnyObject]
dictionary_[key] = newValue.object
self.object = dictionary_
}
......@@ -270,16 +270,16 @@ extension JSON {
private subscript(#sub: SubscriptType) -> JSON {
get {
if sub is String {
return self[key:sub as String]
return self[key:sub as! String]
} else {
return self[index:sub as Int]
return self[index:sub as! Int]
}
}
set {
if sub is String {
self[key:sub as String] = newValue
self[key:sub as! String] = newValue
} else {
self[index:sub as Int] = newValue
self[index:sub as! Int] = newValue
}
}
}
......@@ -440,16 +440,16 @@ extension JSON: RawRepresentable {
switch self.type {
case .Array, .Dictionary:
if let data = self.rawData(options: opt) {
return NSString(data: data, encoding: encoding)
return NSString(data: data, encoding: encoding) as! String
} else {
return nil
}
case .String:
return (self.object as String)
return (self.object as! String)
case .Number:
return (self.object as NSNumber).stringValue
return (self.object as! NSNumber).stringValue
case .Bool:
return (self.object as Bool).description
return (self.object as! Bool).description
case .Null:
return "null"
default:
......@@ -483,7 +483,7 @@ extension JSON {
public var array: [JSON]? {
get {
if self.type == .Array {
return map(self.object as [AnyObject]){ JSON($0) }
return map(self.object as! [AnyObject]){ JSON($0) }
} else {
return nil
}
......@@ -533,7 +533,7 @@ extension JSON {
public var dictionary: [String : JSON]? {
get {
if self.type == .Dictionary {
return _map(self.object as [String : AnyObject]){ JSON($0) }
return _map(self.object as! [String : AnyObject]){ JSON($0) }
} else {
return nil
}
......@@ -634,11 +634,11 @@ extension JSON {
get {
switch self.type {
case .String:
return self.object as String
return self.object as! String
case .Number:
return self.object.stringValue
case .Bool:
return (self.object as Bool).description
return (self.object as! Bool).description
default:
return ""
}
......@@ -672,15 +672,15 @@ extension JSON {
get {
switch self.type {
case .String:
let scanner = NSScanner(string: self.object as String)
let scanner = NSScanner(string: self.object as! String)
if scanner.scanDouble(nil){
if (scanner.atEnd) {
return NSNumber(double:(self.object as NSString).doubleValue)
return NSNumber(double:(self.object as! NSString).doubleValue)
}
}
return NSNumber(double: 0.0)
case .Number, .Bool:
return self.object as NSNumber
return self.object as! NSNumber
default:
return NSNumber(double: 0.0)
}
......@@ -1008,15 +1008,15 @@ public func ==(lhs: JSON, rhs: JSON) -> Bool {
switch (lhs.type, rhs.type) {
case (.Number, .Number):
return (lhs.object as NSNumber) == (rhs.object as NSNumber)
return (lhs.object as! NSNumber) == (rhs.object as! NSNumber)
case (.String, .String):
return (lhs.object as String) == (rhs.object as String)
return (lhs.object as! String) == (rhs.object as! String)
case (.Bool, .Bool):
return (lhs.object as Bool) == (rhs.object as Bool)
return (lhs.object as! Bool) == (rhs.object as! Bool)
case (.Array, .Array):
return (lhs.object as NSArray) == (rhs.object as NSArray)
return (lhs.object as! NSArray) == (rhs.object as! NSArray)
case (.Dictionary, .Dictionary):
return (lhs.object as NSDictionary) == (rhs.object as NSDictionary)
return (lhs.object as! NSDictionary) == (rhs.object as! NSDictionary)
case (.Null, .Null):
return true
default:
......@@ -1028,15 +1028,15 @@ public func <=(lhs: JSON, rhs: JSON) -> Bool {
switch (lhs.type, rhs.type) {