如何实施ChimpKit3?

时间:2016-08-11 07:06:25

标签: objective-c

关于github的ChimpKit自述文件中的示例,我遇到了很大的困难。

NSDictionary *params = @{@"id": @"8ce4588803", @"email": @{@"email": @"foo@example.com"}, @"merge_vars": @{@"FNAME": @"Freddie", @"LName":@"von Chimpenheimer"}};
    [[ChimpKit sharedKit] callApiMethod:@"lists/subscribe" withParams:params andCompletionHandler:^(ChimpKitRequest *request, NSError *error) {
        NSLog(@"HTTP Status Code: %d", request.response.statusCode);
        NSLog(@"Response String: %@", request.responseString);

        if (error) {
            //Handle connection error
            NSLog(@"Error, %@", error);
            dispatch_async(dispatch_get_main_queue(), ^{
                //Update UI here
            });
        } else {
            NSError *parseError = nil;
            id response = [NSJSONSerialization JSONObjectWithData:request.responseData
                                                          options:0
                                                            error:&parseError];
            if ([response isKindOfClass:[NSDictionary class]]) {
                id email = [response objectForKey:@"email"];
                if ([email isKindOfClass:[NSString class]]) {
                    //Successfully subscribed email address
                    dispatch_async(dispatch_get_main_queue(), ^{
                        //Update UI here
                    });
                }
            }
        }
    }];

显然,这是在MailChimp

中订阅电子邮件到列表的代码

我收到错误:

  

/SubscribeEmailViewController.m:146:105:预期')'

     

SubscribeEmailViewController.m:146:103:缺少类型说明符,   默认为'int'

     

SubscribebeE​​mailViewController.m:147:44:使用未声明的标识符   '请求'

     

SubscribeEmailViewController.m:146:103:不兼容的块指针   将'int((^)(void))'发送到类型参数的类型   'ChimpKitRequestCompletionBlock'(又名'void(^)(NSURLResponse   * __ strong,NSData * __ strong,NSError * __ strong)')

这基本上是复制和粘贴的例子,我无法弄清楚我在这里缺少什么细节。 ChimpKit是通过cocoapods安装的

0 个答案:

没有答案