If I am type self
and then press the dot
(e.g. self.|) it’s converts the line to 'self.'
(quotes in typographic) this drives me mad
Crash Type: Code Completion
Items in CC:
asString()
dynamicType
escape(, asASCII:)
isASCII()
ReferenceEquals()
self
stride(, through: , by:)
stride(, to: , by:)
ToUTF16()
ToUTF16String()
writeTo()
Solution:
Project: file:///Users/x/Development/Projects/x/x/version%2D3/config%2Dapp/x/x.elements
File: file:///Users/x/Development/Projects/x/x/version%2D3/config%2Dapp/x/View%20Controllers/ClientsViewController.swift
Position: line 31 column 17
Current Line: `Self`.
............. ^
Current Token: ''
Error(s): 2 lines above: Parameter 1 is "<method group>", should be "BOOL", in call to func UIViewController!.viewDidAppear(_ animated: BOOL)
Full File:
import UIKit
public protocol ClientPickerControllerDelegate: class {
func clientPickerViewController(_ clientPickerViewController: ClientsViewController, didSelectClient client: Client)
}
@IBObject public class ClientsViewController: UITableViewController {
var clients = [Client]()
public var viewModel: Client?
public weak var delegate: ClientPickerControllerDelegate?
public init(viewModel: Client?) {
self.viewModel = viewModel
super.init()
}
public override func viewDidLoad() {
super.viewDidLoad()
title = "Select Client"
// Uncomment the following line to preserve selection between presentations.
clearsSelectionOnViewWillAppear = false
}
public override func viewDidAppear(_ animated: BOOL) {
super.viewDidAppear(animated)
`Self`.
ClientService.sharedInstance.getAvailableClients() { result in
switch (result) {
case .success(let results):
DispatchQueue.main.async { // ADD BREAKPOINT
self.clients = results as? ClientList
self.tableView.reloadData()
}
case .failure(let error):
print("error: \(error)")
// switch state to -> error
}
}
}
public override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//
// Table view data source
//
private func numberOfSectionsInTableView(_ tableView: UITableView!) -> Int {
// Return the number of sections.
return 1
}
private func tableView(_ tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
// Return the number of rows in the section.
return self.clients.count
}
private func tableView(_ tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell {
let cellIdentifier = "RootViewControllerCell"
var cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier)
if cell == nil {
cell = UITableViewCell(style: .Default, reuseIdentifier: cellIdentifier)
let relevantClient = self.clients[indexPath.item]
cell.textLabel?.text = "\(relevantClient.name)"
cell.accessoryType = .disclosureIndicator
}
// Configure the individual cell...
return cell!
}
//
// Table view delegate
//
private func tableView(_ tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
guard let selectedClient = self.clients[indexPath.item] as? Client else {
return
}
Loggly.log("Selected Client: \(selectedClient)")
self.delegate?.clientPickerViewController(self, didSelectClient: selectedClient)
}
}Managed File:
import UIKit
public protocol ClientPickerControllerDelegate: class {
func clientPickerViewController(_ clientPickerViewController: ClientsViewController, didSelectClient client: Client)
}
@IBObject public class ClientsViewController: UITableViewController {
var clients = [Client]()
public var viewModel: Client?
public weak var delegate: ClientPickerControllerDelegate?
public init(viewModel: Client?) {
self.viewModel = viewModel
super.init()
}
public override func viewDidLoad() {
super.viewDidLoad()
title = "Select Client"
// Uncomment the following line to preserve selection between presentations.
clearsSelectionOnViewWillAppear = false
}
public override func viewDidAppear(_ animated: BOOL) {
super.viewDidAppear(animated)
`Self`.
ClientService.sharedInstance.getAvailableClients() { result in
switch (result) {
case .success(let results):
DispatchQueue.main.async { // ADD BREAKPOINT
self.clients = results as? ClientList
self.tableView.reloadData()
}
case .failure(let error):
print("error: \(error)")
// switch state to -> error
}
}
}
public override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//
// Table view data source
//
private func numberOfSectionsInTableView(_ tableView: UITableView!) -> Int {
// Return the number of sections.
return 1
}
private func tableView(_ tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
// Return the number of rows in the section.
return self.clients.count
}
private func tableView(_ tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell {
let cellIdentifier = "RootViewControllerCell"
var cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier)
if cell == nil {
cell = UITableViewCell(style: .Default, reuseIdentifier: cellIdentifier)
let relevantClient = self.clients[indexPath.item]
cell.textLabel?.text = "\(relevantClient.name)"
cell.accessoryType = .disclosureIndicator
}
// Configure the individual cell...
return cell!
}
//
// Table view delegate
//
private func tableView(_ tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
guard let selectedClient = self.clients[indexPath.item] as? Client else {
return
}
Loggly.log("Selected Client: \(selectedClient)")
self.delegate?.clientPickerViewController(self, didSelectClient: selectedClient)
}
}