Google Api error “Multiple methods named 'initWithArray:' found”

杀马特。学长 韩版系。学妹 提交于 2019-12-28 12:32:10

问题


I am using the google calendar api and I am getting two errors.

  1. GTMGatherInputStream.m:25:13: Multiple methods named 'initWithArray:' found

    #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' file not found

    #if GTM_USE_SESSION_FETCHER
    #import "GTMSessionFetcher.h" //GTMSessionFetcher.h file not found error
    #else
    #import "GTMHTTPFetcher.h"
    #endif  // GTM_USE_SESSION_FETCHER
    

I have researched the error everywhere online and I have found nothing. I am running GM El capitan with GM Xcode 7.0. I Have tried multiple different ways on solving it and nothing has worked. My code will not compile. How do I fix this?


回答1:


I assume Google is going to implement a fix for this in the near future; in the meantime, we can do a couple of hacks to get around those issues:

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

    to

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

  2. change

    #ifndef GTM_USE_SESSION_FETCHER
    #define GTM_USE_SESSION_FETCHER 1
    #endif
    

    to

    #ifndef GTM_USE_SESSION_FETCHER
    #define GTM_USE_SESSION_FETCHER 0
    #endif
    

I had to do this in two places where GTM_USE_SESSION_FETCHER was defined.

One final thing, was to go to the GTL project build settings, and set Apple LLVM 7.0 warnings Deprecated Functions to NO. With these 3 steps the Calendar API compiles successfully on iOS9.




回答2:


I also had to deal with an error Comparison of address of ... not equal to null pointer is always true

This was causing the app not to build. Had to modify lines 340 and 1088 of GTMOAuth2ViewControllerTouch.m

E.g.,

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



回答3:


Change self in [[[self alloc] initWithArray:dataArray] autorelease] to GTMGatherInputStream. It's working for me:

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


来源:https://stackoverflow.com/questions/32615688/google-api-error-multiple-methods-named-initwitharray-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!