起初,我对Obj-C非常苛刻(不喜欢语法),但现在我喜欢用iPhone开发:D
这是我的问题,我尝试使用Obj-C库(xmppframework),但是当我尝试初始化XMPPRoster时,所需的方法不可用...
xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] initWithInMemoryStore];
xmppRoster = [[XMPPRoster alloc] initWithRosterStorage:xmppRosterStorage];
但是在我的Swift类中,方法“initWithRosterStorage”不可用:(
var jabberRosterStorage: XMPPCoreDataStorage = XMPPCoreDataStorage()
var jabberRoster:XMPPRoster = XMPPRoster(....)
XMPPRoster.m:
- (id)initWithRosterStorage:(id <XMPPRosterStorage>)storage
{
return [self initWithRosterStorage:storage dispatchQueue:NULL];
}
也许Swift对(id)有问题,因为在Swift中我认为它现在是AnyObject
答案 0 :(得分:1)
尝试在Swift中初始化它:
var jabberRosterStorage: XMPPCoreDataStorage, XMPPRosterStorage = XMPPCoreDataStorage()
var jabberRoster: XMPPRoster = XMPPRoster(rosterStorage: jabberRosterStorage)
Swift会将[[Class alloc] initWithVar:variable]
转换为Class(var: variable)
。