Objective c id值=[[error userInfo]objectForKey:AverRorRecordingSuccessfullyFinisheKey]到Swift

Objective c id值=[[error userInfo]objectForKey:AverRorRecordingSuccessfullyFinisheKey]到Swift,objective-c,swift,Objective C,Swift,我正试图在swift中构建一个摄像头应用程序,我在互联网上搜索了一些代码,发现了这几行代码 (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error { NSLog(@"didFinishRecord

我正试图在swift中构建一个摄像头应用程序,我在互联网上搜索了一些代码,发现了这几行代码

(void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error {

NSLog(@"didFinishRecordingToOutputFileAtURL - enter");

BOOL RecordedSuccessfully = YES;
if ([error code] != noErr)
{
    // A problem occurred: Find out if the recording was successful.
    id value = [[error userInfo] objectForKey:AVErrorRecordingSuccessfullyFinishedKey];
    if (value)
    {
        RecordedSuccessfully = [value boolValue];
    }
}
...
如何写入id值=[[error userInfo]objectForKey:AVErrorRecordingSuccessfullyFinishedKey];斯威夫特

我尝试:

value = error.userInfo[AVErrorRecordingSuccessfullyFinishedKey]

但它向我显示了这个错误:“NSString不能转换为‘DictionaryIndex’

因此,您可以用swift的方式编写这行代码:

var value: AnyObject! = error.userInfo[AVErrorRecordingSuccessfullyFinishedKey]
UPD:

根据此警告,您使用的xCode beta版本低于5:

'NSString不能转换为'DictionaryIndex'


更新它

试一试,你觉得会是什么样子?我调整一下,等一下。