Google Api错误"多个名为' initWithArray的方法:'发现"

时间:2015-09-16 18:08:13

标签: objective-c swift api google-api xcode7

我正在使用谷歌日历api,我收到两个错误。

  1. GTMGatherInputStream.m:25:13:名为' initWithArray的多个方法:'结果

    #import "GTMGatherInputStream.h"
    @implementation GTMGatherInputStream
    + (NSInputStream *)streamWithArray:(NSArray *)dataArray {
        return [[[self alloc] initWithArray:dataArray] autorelease]; //error on this line
    }
    
  2. GTMOAuth2Authentication.h:31:11:' GTMSessionFetcher.h'找不到文件

    #if GTM_USE_SESSION_FETCHER
    #import "GTMSessionFetcher.h" //GTMSessionFetcher.h file not found error
    #else
    #import "GTMHTTPFetcher.h"
    #endif  // GTM_USE_SESSION_FETCHER
    
  3. 我在网上到处研究过这个错误,但我什么都没发现。我正在使用GM Xcode 7.0运行GM El capitan。我已经尝试了多种不同的方法来解决它,但没有任何方法可行。我的代码不会编译。我该如何解决?

3 个答案:

答案 0 :(得分:15)

我认为Google将在不久的将来为此实施此修复程序;与此同时,我们可以做几个黑客来解决这些问题:

  1. 更改return [[[self alloc] initWithArray:dataArray] autorelease];

    return [[(GTMGatherInputStream*)[self alloc] initWithArray:dataArray] autorelease];

  2. 更改

    #ifndef GTM_USE_SESSION_FETCHER
    #define GTM_USE_SESSION_FETCHER 1
    #endif
    

    #ifndef GTM_USE_SESSION_FETCHER
    #define GTM_USE_SESSION_FETCHER 0
    #endif
    
  3. 我必须在定义GTM_USE_SESSION_FETCHER的两个地方执行此操作。

    最后一件事是转到GTL项目构建设置,并将Apple LLVM 7.0警告Deprecated Functions设置为NO。通过这3个步骤,Calendar API在iOS9上成功编译。

答案 1 :(得分:0)

我还必须处理错误Comparison of address of ... not equal to null pointer is always true

这导致应用程序无法构建。必须修改GTMOAuth2ViewControllerTouch.m

的第340和1088行

如,

  // CGP; 9/30/15; took out "&" before kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
  //if (accessibility == NULL
  //    && &kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly != NULL) {
  if (accessibility == NULL
        && kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly != NULL) {
    accessibility = kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly;
  }

答案 2 :(得分:0)

[[[self alloc] initWithArray:dataArray] autorelease]中的自我更改为GTMGatherInputStream。它为我工作:

#import "GTMGatherInputStream.h"
@implementation GTMGatherInputStream
+ (NSInputStream *)streamWithArray:(NSArray *)dataArray {
    return [[[GTMGatherInputStream alloc] initWithArray:dataArray] autorelease];
}
相关问题