标签: conform

Swift中的纯类协议

我希望我的一些课程(不是全部)能够使用docs中的"Class-Only Protocols".我在做什么

protocol RefreshData: class, ClassA, ClassB
{
    func updateController()
}
Run Code Online (Sandbox Code Playgroud)

我收到了错误

non class type 'RefreshData cannot inherit from classA
non class type 'RefreshData cannot inherit from classB
Run Code Online (Sandbox Code Playgroud)

我不确定我是否完全遵循文档.有没有人对此有任何想法?

protocols ios conform swift swift2

30
推荐指数
3
解决办法
2万
查看次数

NHibernate关系存在双向获取数据的问题

我有2个表有多对多的关系.

实体代码

public class Product : BaseEntity
{     
    public virtual string Name { get; set; }
    public virtual IList<Category> ProductCategory { get; set; }
    public virtual float Price { get; set; }
    public virtual string Description { get; set; }
    public virtual DateTime DateOfAdd { get; set; }
    public virtual float Discount { get; set; }
    public virtual int SaleCount { get; set; }
    public virtual byte[] Image { get; set; }
}

public class Category : BaseEntity
{
    public …
Run Code Online (Sandbox Code Playgroud)

.net c# nhibernate conform

6
推荐指数
1
解决办法
436
查看次数

如何根据Swift中的String创建对象?

这是我想要重构的代码:

let myCell = MyCustomTableViewCell()
self.createCell(myCell, reuseIdentifierString: "myCellIdentifier")
Run Code Online (Sandbox Code Playgroud)

MyCustomTableViewCell符合SetCell协议,因此工作正常.并且SetCell协议不是@obj_c协议.这是一个迅速的协议

private func createCell<T where T:SetCell>(classType: T, reuseIdentifierString: String) -> UITableViewCell {
  var cell = _tableView.dequeueReusableCellWithIdentifier(reuseIdentifierString) as T
  cell.setText()
  return cell.getCustomCell()
}
Run Code Online (Sandbox Code Playgroud)

现在我重构我的代码,我想根据字符串创建myCell,但字符串与我的类名完全相同.我不想使用else-if或switch-case

let myCell: AnyClass! = NSClassFromString("MyCustomTableViewCell")
self.createCell(myCell, reuseIdentifierString: "myCellIdentifier")
Run Code Online (Sandbox Code Playgroud)

但现在,AnyClass的myCell不符合协议.我怎样才能做到这一点?

generics protocols ios conform swift

5
推荐指数
1
解决办法
2431
查看次数

有没有办法在开发过程中使合规工作?

我在Phoenix应用程序中使用Conform配置.这需要exrm发布.出于开发目的,我们希望使用相同的配置技术,但每次进行更改时都不会生成发布.有没有办法在运行时使用Conform mix phoenix.server

elixir conform

5
推荐指数
1
解决办法
228
查看次数

如何使用子类遵守协议

说我有一个协议

protocol A: class {
  func configure(view: UIView)
}
Run Code Online (Sandbox Code Playgroud)

现在,我想遵循此协议,将其UILabel用作UIView

final class B: A {
  init() {}

  func configure(view: UILabel) {

  }
}
Run Code Online (Sandbox Code Playgroud)

但是错误

类型B不符合协议A

似乎Swift需要与协议中所述的类型完全相同。这有效

final class B: A {
  init() {}

  func configure(view: UIView) {

  }
}
Run Code Online (Sandbox Code Playgroud)

但是我要使用UILabel,如何解决此问题?

protocols class subclass conform swift

2
推荐指数
1
解决办法
540
查看次数

类型不符合协议'ImagePickerDelegate'

我正在使用来自github的名为ImagePicker的库来获取用户的图像并上传它们.但是,当我实现此处的示例代码时,我收到以下错误:

类型'changeCoverViewController'不符合协议'ImagePickerDelegate'

在第一行代码:

class changeCoverViewController: UIViewController, ImagePickerDelegate {
Run Code Online (Sandbox Code Playgroud)

types ios conform swift

1
推荐指数
1
解决办法
575
查看次数

标签 统计

conform ×6

swift ×4

ios ×3

protocols ×3

.net ×1

c# ×1

class ×1

elixir ×1

generics ×1

nhibernate ×1

subclass ×1

swift2 ×1

types ×1