gpt4 book ai didi

ios - Youtube 与 iOS 应用程序集成 - 意外错误

转载 作者:行者123 更新时间:2023-11-29 10:54:18 25 4
gpt4 key购买 nike


我正在关注这个例子 https://code.google.com/p/google-api-objectivec-client/source/browse/#svn/trunk/Examples/YouTubeSample将 YouTube SDK 集成到我的 iOS 应用中。
以下是我做过的一些工作:
- 将 GTL.project 添加到我的项目中,并为 Header Search Path 设置源路径。
- 将 GTLTouchStaticLib 链接到链接二进制文件与我的项目的库。
- 将 GTLYouTube_Sources.m 添加到我的项目中。
- 从 YouTubeSample 复制一些代码,这里是代码片段:

#import "ViewController.h"

#import "GTLYouTube.h"

#import "GTLUtilities.h"
#import "GTMHTTPUploadFetcher.h"
#import "GTMHTTPFetcherLogging.h"
#import "GTMOAuth2ViewControllerTouch.h"
.
.
- (IBAction)Login:(id)sender {

GTMOAuth2ViewControllerTouch *viewController;
viewController = [[GTMOAuth2ViewControllerTouch alloc] initWithScope:kGTLAuthScopeYouTube
clientID:kMyClientID
clientSecret:kMyClientSecret
keychainItemName:kKeychainItemName
delegate:self
finishedSelector:@selector(viewController:finishedWithAuth:error:)];

[self presentViewController:viewController animated:YES completion:NULL];
}

- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error {
if (error == nil) {
self.youTubeService.authorizer = auth;
// [self dismissViewControllerAnimated:YES completion:NULL];
[self fetchMyChannelList];
} else {
NSLog(@"Auth failed: %@", error);
}
}

- (void)fetchMyChannelList {
NSLog(@"fetchMyChannelList");
_myPlaylists = nil;
_channelListFetchError = nil;

GTLServiceYouTube *service = self.youTubeService;

GTLQueryYouTube *query = [GTLQueryYouTube queryForChannelsListWithPart:@"contentDetails"];

query.mine = YES;

// maxResults specifies the number of results per page. Since we earlier
// specified shouldFetchNextPages=YES, all results should be fetched,
// though specifying a larger maxResults will reduce the number of fetches
// needed to retrieve all pages.
query.maxResults = 50;

// We can specify the fields we want here to reduce the network
// bandwidth and memory needed for the fetched collection.
//
// For example, leave query.fields as nil during development.
// When ready to test and optimize your app, specify just the fields needed.
// For example, this sample app might use
//
// query.fields = @"kind,etag,items(id,etag,kind,contentDetails)";

_channelListTicket = [service executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLYouTubeChannelListResponse *channelList,
NSError *error) {
// Callback

// The contentDetails of the response has the playlists available for
// "my channel".
if ([[channelList items] count] > 0) {
GTLYouTubeChannel *channel = channelList[0];
_myPlaylists = channel.contentDetails.relatedPlaylists;
NSLog(@"_myPlaylists: %@", _myPlaylists);
}
_channelListFetchError = error;
_channelListTicket = nil;

if (_myPlaylists) {
[self fetchSelectedPlaylist];
}

[self fetchVideoCategories];
}];

}

构建并运行后,我使用我的 youtube 帐户登录,当我在页面中单击同意时,应用程序崩溃,错误输出如下:

2013-09-30 04:12:47.618 YoutubeAPITest[4153:a0b] popView2013-09-30 04:12:48.684 YoutubeAPITest[4153:a0b] fetchMyChannelList2013-09-30 04:12:48.685 YoutubeAPITest[4153:a0b] GTLRuntimeCommon: unexpected attributes TB,D for property mine2013-09-30 04:12:48.685 YoutubeAPITest[4153:a0b] GTLRuntimeCommon: unexpected return type class  for property "mine" of class "GTLQueryYouTube"2013-09-30 04:12:48.686 YoutubeAPITest[4153:a0b] -[GTLQueryYouTube setMine:]: unrecognized selector sent to instance 0x1090c13e02013-09-30 04:12:48.689 YoutubeAPITest[4153:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GTLQueryYouTube setMine:]: unrecognized selector sent to instance 0x1090c13e0'*** First throw call stack:(    0   CoreFoundation                      0x0000000101a7c795 __exceptionPreprocess + 165    1   libobjc.A.dylib                     0x00000001017df991 objc_exception_throw + 43    2   CoreFoundation                      0x0000000101b0dbad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205    3   CoreFoundation                      0x0000000101a6e09d ___forwarding___ + 973    4   CoreFoundation                      0x0000000101a6dc48 _CF_forwarding_prep_0 + 120    5   YoutubeAPITest                      0x0000000100001ae2 -[ViewController fetchMyChannelList] + 258    6   YoutubeAPITest                      0x000000010000197a -[ViewController viewController:finishedWithAuth:error:] + 218    7   CoreFoundation                      0x0000000101a7222c __invoking___ + 140    8   CoreFoundation                      0x0000000101a720d4 -[NSInvocation invoke] + 308    9   YoutubeAPITest                      0x000000010001474d -[GTMOAuth2ViewControllerTouch signIn:finishedWithAuth:error:] + 701    10  CoreFoundation                      0x0000000101a7222c __invoking___ + 140    11  CoreFoundation                      0x0000000101a720d4 -[NSInvocation invoke] + 308    12  YoutubeAPITest                      0x00000001000113cf -[GTMOAuth2SignIn invokeFinalCallbackWithError:] + 415    13  YoutubeAPITest                      0x000000010001121e -[GTMOAuth2SignIn finishSignInWithError:] + 62    14  YoutubeAPITest                      0x0000000100010daa -[GTMOAuth2SignIn fetchGoogleUserInfo] + 506    15  YoutubeAPITest                      0x000000010001096b -[GTMOAuth2SignIn auth:finishedWithFetcher:error:] + 251    16  CoreFoundation                      0x0000000101a7222c __invoking___ + 140    17  CoreFoundation                      0x0000000101a720d4 -[NSInvocation invoke] + 308    18  YoutubeAPITest                      0x000000010000df43 +[GTMOAuth2Authentication invokeDelegate:selector:object:object:object:] + 355    19  YoutubeAPITest                      0x000000010000c856 -[GTMOAuth2Authentication tokenFetcher:finishedWithData:error:] + 1334    20  CoreFoundation                      0x0000000101a7222c __invoking___ + 140    21  CoreFoundation                      0x0000000101a720d4 -[NSInvocation invoke] + 308    22  YoutubeAPITest                      0x000000010001add8 -[GTMHTTPFetcher invokeFetchCallback:target:data:error:] + 344    23  YoutubeAPITest                      0x000000010001ac4c -[GTMHTTPFetcher invokeFetchCallbacksWithData:error:] + 204    24  YoutubeAPITest                      0x000000010001c165 -[GTMHTTPFetcher connectionDidFinishLoading:] + 1333    25  Foundation                          0x00000001014d103b __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 48    26  Foundation                          0x000000010138476b -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 210    27  Foundation                          0x000000010138467c -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 69    28  CFNetwork                           0x00000001068c88b7 ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 107    29  CFNetwork                           0x00000001068c6a82 ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 84    30  CFNetwork                           0x000000010690a024 ___ZNK17CoreSchedulingSet13_performAsyncEPKcU13block_pointerFvvE_block_invoke + 25    31  CoreFoundation                      0x0000000101a230b4 CFArrayApplyFunction + 68    32  CFNetwork                           0x0000000106839d7b _ZN19RunloopBlockContext7performEv + 115    33  CFNetwork                           0x0000000106839bc1 _ZN17MultiplexerSource7performEv + 247    34  CFNetwork                           0x00000001068399e4 _ZN17MultiplexerSource8_performEPv + 72    35  CoreFoundation                      0x0000000101a0be61 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17    36  CoreFoundation                      0x0000000101a0b732 __CFRunLoopDoSources0 + 242    37  CoreFoundation                      0x0000000101a275bf __CFRunLoopRun + 767    38  CoreFoundation                      0x0000000101a26ed3 CFRunLoopRunSpecific + 467    39  GraphicsServices                    0x0000000103b1d3a4 GSEventRunModal + 161    40  UIKit                               0x0000000100447a63 UIApplicationMain + 1010    41  YoutubeAPITest                      0x0000000100008c13 main + 115    42  libdyld.dylib                       0x00000001020ef7e1 start + 0    43  ???                                 0x0000000000000001 0x0 + 1)libc++abi.dylib: terminating with uncaught exception of type NSException(lldb) 

好像认证成功了,但是fetchMyChannelList失败了:错误发生在为query的mine属性设置值的时候。我已经重新检查了所有步骤,但无法找出问题所在,请帮忙。

最佳答案

我刚刚在使用 Google Calendar api 时遇到了同样的问题。

GTLRuntimeCommon:属性 singleEvents 的意外属性 TB、D

如果您使用的是在 Cocoa Pods 上找到的 Google-API-Client,那么这可能就是原因。我发现在 64 位 iPhone 的查询中设置 bool 值时,cocoapod 有点过时并且会崩溃。来源在这里找到https://code.google.com/p/google-api-objectivec-client/已修复补丁。

如果你对这里的补丁感到好奇 https://code.google.com/p/google-api-objectivec-client/source/detail?r=364

关于ios - Youtube 与 iOS 应用程序集成 - 意外错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19083317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com