- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一个 objective-c 类 (RDAlertView)
,它创建一个警报(iOS < 8 的 UIAlertView 和 ios >=8 的 UIAlertController)
这是 Objective-C 中的代码:
RDAlertView* alert = [[RDAlertView alloc] initWithTitle:@"Notification"
message:@"message"
completion:completion:^(NSInteger buttonIndex, NSInteger cancelButtonIndex, NSArray *textflieds) { }
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
我的问题是:如何在不对我的类进行任何更改的情况下(如果可能)在 Swift 中调用它?
最佳答案
我想这就是你需要的:
var alert = RDAlertView(title: "Notification", message: "message", completion: nil, cancelButtonTitle: "OK", otherButtonTitles: nil)
alert.show()
希望对你有帮助。
关于ios - 如何快速调用 initWith...,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30163783/
我有一个 objective-c 类 (RDAlertView),它创建一个警报(iOS =8 的 UIAlertController) 这是 Objective-C 中的代码: RDAlertVie
例如,我有一个 UIView 的实现。 UIView 包含两个标签,一个图像和一个框架。 我的“init”方法最终看起来像这样: - (id)initWithFrameAndLabelArrayAnd
我正在学习 ObjC 和 Cocoa,这也是我第一次认真尝试一般编程。 我无法区分在实例上调用的 initWith 方法和在类上调用的工厂方法。 首先,为什么将它们称为“工厂”方法,我称为“InitW
如果我为一个对象创建一个自定义 initWith,我是否本质上包含了我想要覆盖 init 时要添加的代码? -(id) init { self = [super init]; if (
我正在创建一个 barbutton 项并将其添加到我的导航 Controller 工具栏 UIBarButtonItem *barButtonItem = [[[UIBarButtonItem all
关于如何确保 View Controller 的 viewDidLoad 上的 outlet 为 nil,我学到了一个非常痛苦的教训,那就是通过编写您自己的 initWith... 方法。 -(id)
例如: 在界面中: @property(retain) NSObject* anObject; 在界面中,实现中: -(id)initWithAnotherObject:(NSObject*)anot
过去,我们受过这样的训练来编写 init 方法: Foo.h: -(id) initWithInteger: (NSInteger) someNumber; Foo.m: -(id) initWith
我是 Objective-C 的新手,我有一个问题。 我创建了一个自定义类并尝试为初始化创建重载: - (id)init { if (self = [super init]) {
创建数组(或使用其各自工厂方法的任何其他集合)的优缺点是什么 [[NSArray alloc] init] 对比 [NSArray array] 在 Objective-C 中?似乎后一种工厂方法让我
我的 Swift-Class 通过以下代码定义了一个 initWith.. 方法 convenience init(controlType: ApplePencilControlType) {
我已经用 Objective-C 编码几个月了,我注意到有时会使用 init 方法实例化一个类(按照文档的建议)。因此,必须先分配,然后初始化。 [[类分配示例] initWithProperty1:
应用程序在初始化 AKMicrohone 时崩溃。 Objective-C AudioKit :4.8 -(void)setupFrequencyDetector{ @try {
我是一名优秀的程序员,十分优秀!