当我尝试在Swift中集成代码时,我遇到了Quickblox的问题。
下面的代码在Objective-C中运行没有任何错误
AppDellgate.m文件
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[QBSettings setApplicationID:kApplicationID];
[QBSettings setAuthKey:kAuthKey];
[QBSettings setAuthSecret:kAuthSecret];
[QBSettings setAccountKey:kAcconuntKey];
[[GeoDataManager instance] fetchLatestCheckIns];
return YES;
}
GeoDataManager.m文件
@implementation GeoDataManager
+ (instancetype)instance
{
static GeoDataManager *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [self new];
});
return instance;
}
- (void)fetchLatestCheckIns
{
QBLGeoDataFilter* filter = [QBLGeoDataFilter new];
filter.lastOnly = YES;
filter.sortBy = GeoDataSortByKindCreatedAt;
QBGeneralResponsePage *page = [QBGeneralResponsePage responsePageWithCurrentPage:1 perPage:70];
[QBRequest geoDataWithFilter:filter page:page successBlock:^(QBResponse *response, NSArray *objects, QBGeneralResponsePage *page) {
[[DataManager sharedDataManager] saveCheckIns:objects];
} errorBlock:^(QBResponse *response) {
NSLog(@"Error = %@", response.error);
}];
}
但是当我尝试从代码
下面的Swift基础项目调用相同的方法时Swift AppDelegate。
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Set QuickBlox credentials (You must create application in admin.quickblox.com).
QBSettings.setApplicationID(kQBApplicationID)
QBSettings.setAuthKey(kQBAuthKey)
QBSettings.setAuthSecret(kQBAuthSecret)
QBSettings.setAccountKey(kQBAccountKey)
GeoDataManager .instance().fetchLatestCheckIns()
return true
}
我收到未捕获的异常'NSInvalidArgumentException',原因是: '+ [QBRequest geoDataWithFilter:page:successBlock:errorBlock:]: 无法识别的选择器被发送到班级。
我已经添加了GeoDataManager&为此创建了一个桥接标题。
任何人都可以帮我解决我做错的事吗?任何想法或建议都会很棒。
答案 0 :(得分:2)
似乎你没有所需的链接器标志
在项目设置中将-lxml2,-ObjC,-lstdc ++标志添加到其他链接器标志部分