【问题标题】:Xcode 8 how to show description of function while typingXcode 8如何在打字时显示功能描述
【发布时间】:2016-10-28 07:36:12
【问题描述】:

如何在键入时显示函数的简要说明,如下图所示?我尝试了许多不同的选项都失败了。

Option + click 有效,但这不是我想要的。

选项 1

 /// Testing...
  /// - returns: false
  func testing()->Bool{
    return false
  }

选项 2

/**
Testing option two
*/
func testing()->Bool{
        return false
}

此问题已在 Xcode 9 中修复

【问题讨论】:

标签: ios swift xcode documentation


【解决方案1】:

如果您正在寻找快速记录自创方法的方法,那么这可能会给您提供一条出路。

import Foundation
/// ? A two-wheeled, human-powered mode of transportation.
class Bicycle {
/**
    Frame and construction style.

    - Road: For streets or trails.
    - Touring: For long journeys.
    - Cruiser: For casual trips around town.
    - Hybrid: For general-purpose transportation.
*/
enum Style {
    case Road, Touring, Cruiser, Hybrid
}

/**
    Mechanism for converting pedal power into motion.

    - Fixed: A single, fixed gear.
    - Freewheel: A variable-speed, disengageable gear.
*/
enum Gearing {
    case Fixed
    case Freewheel(speeds: Int)
}

/**
    Hardware used for steering.

    - Riser: A casual handlebar.
    - Café: An upright handlebar.
    - Drop: A classic handlebar.
    - Bullhorn: A powerful handlebar.
*/
enum Handlebar {
    case Riser, Café, Drop, Bullhorn
}

/// The style of the bicycle.
let style: Style

/// The gearing of the bicycle.
let gearing: Gearing

/// The handlebar of the bicycle.
let handlebar: Handlebar

/// The size of the frame, in centimeters.
let frameSize: Int

/// The number of trips travelled by the bicycle.
private(set) var numberOfTrips: Int

/// The total distance travelled by the bicycle, in meters.
private(set) var distanceTravelled: Double

/**
    Initializes a new bicycle with the provided parts and specifications.

    - Parameters:
        - style: The style of the bicycle
        - gearing: The gearing of the bicycle
        - handlebar: The handlebar of the bicycle
        - frameSize: The frame size of the bicycle, in centimeters

    - Returns: A beautiful, brand-new bicycle, custom built
      just for you.
*/
init(style: Style, gearing: Gearing, handlebar: Handlebar, frameSize centimeters: Int) {
    self.style = style
    self.gearing = gearing
    self.handlebar = handlebar
    self.frameSize = centimeters

    self.numberOfTrips = 0
    self.distanceTravelled = 0
}

/**
    Take a bike out for a spin.

    - Parameter meters: The distance to travel in meters.
*/
func travel(distance meters: Double) {
    if meters > 0 {
        distanceTravelled += meters
        ++numberOfTrips
    }
}
}

Swift-Documentation on NSHipster

【讨论】:

    【解决方案2】:

    我正在使用 Xcode 9.4.1,我发现了这个...

    从函数中自动选择的参数。将光标放在函数上方的行上。

    /// <#Description#>
    ///
    /// - Parameters:
    ///   - param1: <#param1 description#>
    ///   - param2: <#param2 description#>
    

    【讨论】:

      【解决方案3】:

      选择您的函数或将光标放在您的函数之前,然后单击

      Xcode - Editor - Structure -> Add Documentation.
      
      /**
       <#Description#>
       */
      

      保存文件,或者只是重新启动 Xcode。然后在调用相应的函数时检查建议。 我希望这可能会有所帮助。

      【讨论】:

        【解决方案4】:

        你设置了吗:

        首选项 -> 文本编辑 -> 输入时建议完成

        在以下位置安装指南和示例代码也可能会有所帮助:

        首选项 -> 组件 -> 文档选项卡 -> “立即检查并安装”或指南和示例代码旁边的箭头,只需下载一次

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2018-08-23
          • 2016-12-06
          • 2011-07-25
          • 1970-01-01
          • 2017-06-09
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多