ios - SPPlaylist.m 中出现 CocoaLibSpotify 错误

标签 ios spotify cocoalibspotify-2.0

当我尝试构建项目时,我在 827 行上收到以下错误 /PATH_TO_PROJECT/Libs/CocoaLibSpotify/Model/SPPlaylist.m:827:25:Objective-C 指针类型“AVAssetTrack *”到 C 指针类型“sp_track *”(又名“struct sp_track *”)的隐式转换需要桥接 Actor

以下是发生错误的代码:

805 -(void)addItems:(NSArray *)newItems atIndex:(NSUInteger)index callback:(SPErrorableOperationCallback)block {
806     
807     SPDispatchAsync(^{
808         
809         if (newItems.count == 0) {
810             dispatch_async(dispatch_get_main_queue(), ^{
811                 if (block) block([NSError spotifyErrorWithCode:SP_ERROR_INVALID_INDATA]);
812             });
813             return;
814         }
815         
816         sp_track **tracks = malloc(sizeof(sp_track *) * newItems.count);
817         
818         // libSpotify iterates through the array and inserts each track at the given index, 
819         // which ends up reversing the expected order. Defeat this by constructing a backwards
820         // array.
821         for (int currentTrack = (int)newItems.count - 1; currentTrack >= 0; currentTrack--) {
822             
823             sp_track *track;
824             id item = [newItems objectAtIndex:currentTrack];
825             
826             if ([item isKindOfClass:[SPTrack class]])
827                 track = [item track];
828             else
829                 track = [(SPTrack *)((SPPlaylistItem *)item).item track];
830             
831             tracks[currentTrack] = track;
832         }
833         sp_track *const *trackPointer = tracks;
834         
835         if (block)
836             [self.addCallbackStack addObject:block];
837         
838         sp_error errorCode = sp_playlist_add_tracks(self.playlist, trackPointer, (int)newItems.count, (int)index, self.session.session);
839         free(tracks);
840         tracks = NULL;
841         
842         NSError *error = nil;
843         if (errorCode != SP_ERROR_OK)
844             error = [NSError spotifyErrorWithCode:errorCode];
845         
846         if (error && block) {
847             [self.addCallbackStack removeObject:block];
848             dispatch_async(dispatch_get_main_queue(), ^{ block(error); });
849         }
850     });
851 }

感谢您的帮助!

最佳答案

该错误很容易解释 - 您需要进行桥接转换。

track = (__bridge sp_track *)[item track];

track = [(SPPlaylistItem *)item track];

关于ios - SPPlaylist.m 中出现 CocoaLibSpotify 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20499560/

相关文章:

Spotify Web API 客户端范围不起作用

ios - 在Spotify iOS SDK中混合两个AUNode

ios - 将轨道添加到加星标的播放列表时出现 NSArray 异常

ios - 有什么办法可以下载 ('make available offline' ) 的 SPTrack/SPAlbum 而无需将其添加到播放列表中吗?

ios - 使用 CocoaLibSpotify 的离线播放列表

ios - 无法使用地址簿框架在地址簿中保存姓名和电子邮件

ios - 点击时“缩小”UIButton 的图像大小

ios - NSOperation 在 iOS sdk 3.2 上可用吗?

ios - ChatSecure-iOS,[检测到 Travis] GPG 验证已禁用 - 仅为 i386 编译

ios - 获取也使用 spotify 的 facebook 好友