1

难道我做错了什么?这看起来很简单。似乎 getPlaylistWithUUID 正在 UUID 上调用 UUIDString,这应该可以工作,但由于某种原因,该值作为 NSCFString 进入方法。这是斯威夫特 2.3

我已经提交了错误报告,但我想我也会在这里问。

let name = "playlist name"  
let id:NSUUID = NSUUID()  
let library = MPMediaLibrary()  
let metadata = MPMediaPlaylistCreationMetadata.init(name: name)  
metadata.authorDisplayName = "author"  
metadata.descriptionText = "description"  
library.getPlaylistWithUUID(id, creationMetadata: metadata) { (playlist, error) in  
            if error != nil {  
                if playlist != nil {  
                    NSLog("it works - name:\(playlist!.name)")  
                }  
            }  
}  

当它运行时,我得到一个无法识别的选择器崩溃

2016-06-24 10:43:12.563000 bugreport[11008:2243450] -[__NSCFString UUIDString]: unrecognized selector sent to instance 0x170276380  
2016-06-24 10:43:12.570185 bugreport[11008:2243450] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString UUIDString]: unrecognized selector sent to instance 0x170276380'  
*** First throw call stack:  
(0x187949980 0x186f444bc 0x187950778 0x18794d6e0 0x18784e61c 0x192132114 0x19212eff4 0x1917e3c40 0x19212ef88 0x192131f30 0x1920e74a4 0x100010d2c 0x1000113d8 0x18d6d34c4 0x18d6d301c 0x18d6d9648 0x18d6d6c14 0x18d749528 0x18d955cd0 0x18d95b5e0 0x18d95864c 0x189448010 0x189447e7c 0x189448224 0x1878fa3f0 0x1878f9d38 0x1878f7938 0x18782a2e4 0x18d73e6c4 0x18d739438 0x1000123b8 0x1873cc600)  
libc++abi.dylib: terminating with uncaught exception of type NSException  
(lldb)  

此错误意味着在 NSCFString 而不是 UUID 上调用了 UUIDString。我只是想确保我没有忽略某些东西,我传入了正确的类型。对于使用 UUID() 的 Swift 3 中同样的事情发生的价值。

(有足够代表的人可以标记这个 swift2.3 吗?)

4

0 回答 0