1

I am absolute beginner with IOS and XCode and swift and I am doing my first tries with Xcode in a Yosemite built in a Vmware running under Windows7 (guest is MAC yosemite, Host is windows running vmware workstation 9 )

I have a ViewController Class in my IOS project declared as follow:

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {...}

Now I would like to implement the necessary methods of the protocols UIViewController and UITableViewDelegate.

In a tutorial

http://jamesonquave.com/blog/developing-ios-apps-using-swift-tutorial/

it says I have to use Command+Click on a protocoll to show which methods should be implemented.

I don't know howto do "command+click on the protocoll" this with my vmware.

any hints ?

When using Alt+clicking on a protocoll it shows me the help. If I am WindowsButton+clicking on a protocoll it opens a new window with sourcecode of the protocoll. Now howto show methods, which should be implemented.

Cœur
  • 37,241
  • 25
  • 195
  • 267
mcfly soft
  • 11,289
  • 26
  • 98
  • 202
  • 1
    So this is a question about VMware, and not about Swift or iOS, and not a programming question ... – Martin R Feb 09 '15 at 16:14

2 Answers2

1

To help you out, UIViewController is a class, which you are subclassing. It is not a protocol, so it doesn't have any necessary methods for you to implement. You can however override the methods you inherit, which is what you see in when you first create the file, ex.

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

This overrides the method you inherited from UIViewController. If you aren't doing anything other than calling super.viewDidLoad() you can remove the entire function from your code.

Now UITableViewDataSource and UITableViewDelegate or both protocols, so they may or may not have required methods to implement.

What you describe when you alt-click, is the same as if you right clicked on UITableViewDataSource and selected jump to definition. This is what you get when you command click on an actual Mac. What the tutorial is saying is that the required methods will be at the top, which isn't always the case if you look at the documentation (as the methods are organized more by purpose there). In the case of UITableViewDataSource, you should see something like:

protocol UITableViewDataSource : NSObjectProtocol {

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell

optional func numberOfSectionsInTableView(tableView: UITableView) -> Int // Default is 1 if not implemented

optional func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? // fixed font style. use custom view (UILabel) if you want something different
optional func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String?

You will notice that the first two methods func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int and func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell do not have optional in front of them. This means that these are the required methods for this protocol. The optional ones below that are optional.

In the case of UITableViewDelegate you'll see that there are no non-optional methods, and therefore it does not require you to implement any.

Jeremy Pope
  • 3,342
  • 1
  • 16
  • 17
  • Ok. I guess I understood. So the Alt-Click is whats Command+Click on a MAC. Thanks a lot you for explanation. – mcfly soft Feb 09 '15 at 19:20
0

You are doing the right thing when you windows click the protocol name to jump to its definition, which is basically just a list of all its methods you can copy and paste into your code


Edit the below is for changing keyboards:


You could try swaping the keys like this:

I don't like putting external source links because they sometimes dissapear so below is the text in their how to:

To swap the Option/Alt key and the Command/Windows key:

Fusion 2.x and later

  1. Go to VMware Fusion > Preferences.
  2. Click Keyboard & Mouse, and then Key Mappings.
  3. Find the line that has a Mac Shortcut of Option, and double-click it to edit it.

    • If you don't see this line, click the + button and then select Option in the top row of keys.
  4. In the To mapping in the bottom row of keys ensure that Alt is not slected and that the Windows logo is selected.This will ensure that pressing the Option key will send the Windows key to the virtual machine.

  5. Click OK.
  6. Find the line that has a Mac Shortcut of the command key logo, and double-click it to edit it.

    • If you don't see this line, click the + button and then select the command key logo in the top row of keys.
  7. In the To mapping in the bottom row of keys ensure that the Windows logo is not selected and that Alt is selected.This will ensure that pressing the Command key will send the Alt key to the virtual machine. Click OK.

Fusion 1.x

  1. Shut down your virtual machine and quit Fusion.
  2. Navigate to [Macintosh HD]//Library/Preferences/VMware Fusion
  3. Ctrl-click the config file and select Open with.
  4. Select TextEdit and click Open. Add the line:

    -mks.keyboard.swapAlt = TRUE

When your virtual machine starts, the Option/Alt key and the Command/Windows key are reversed.

jamesC
  • 422
  • 6
  • 25
  • I am not sure if I understand correctly, but is this not the opposite way ? I do not have VMWare Fusion and I do not have a mac. I have a windows pc and I am running a MAC built in a vmware. Now I don't know which is the macs command key ? – mcfly soft Feb 09 '15 at 16:34
  • I did not think that the licensing for OS X allows for this scenario. I'm not a licensing expert, but I am under the impression that virtualizing OS X still requires the host to be running on Mac Hardware. – Jeremy Pope Feb 09 '15 at 17:46
  • So i read your question wrong sorry. You are doing the right thing when you windows click the protocol name to jump to its definition, which is basically just a list of all its methods you can copy and paste into your code – jamesC Feb 09 '15 at 17:49
  • @james thank you. So the windows key is representing the command key of a mac ? – mcfly soft Feb 09 '15 at 19:18
  • yeah (for the most part) still tricks me up sometimes though. I have a mac and pc keyboard hooked up to my mac (i use them both at the sametime to save myself the frustration.. ha) Windows --Macintosh CONTROL = COMMAND (for most shortcuts) or CONTROL ALT= OPTION Windows/Start = COMMAND/Apple – jamesC Feb 09 '15 at 19:25