【问题标题】:Quickblox APIs in swift crashes with unrecognized selectorQuickblox API 在 swift 中因无法识别的选择器而崩溃
【发布时间】:2016-02-08 20:33:26
【问题描述】:

我在尝试在 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 并为其创建了一个桥接头。

谁能帮我解决我做错了什么?任何想法或建议都会很棒。

【问题讨论】:

    标签: ios swift quickblox


    【解决方案1】:

    似乎您不需要链接器标志

    1. 完整指南http://quickblox.com/developers/IOS-how-to-connect-Quickblox-framework
    2. 请看第 7 步:

    将 -lxml2、-ObjC、-lstdc++ 标志添加到项目设置中的其他链接器标志部分

    【讨论】:

      猜你喜欢
      • 2015-01-08
      • 2012-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-25
      • 2016-07-05
      • 2017-04-26
      • 2019-10-24
      相关资源
      最近更新 更多