我更新了xcode 7并给出了这个错误
Null传递给需要非null参数的被调用者
_recorder = [[AVAudioRecorder alloc]initWithURL:[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@.%@", [NSHomeDirectory() stringByAppendingString:@"/Documents"], name, extension]] settings:nil error:nil];
Run Code Online (Sandbox Code Playgroud)
rui*_*ano 31
如果困扰你的是警告,你可以使用它来压制它 -Wnonnull
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonnull"
_recorder = [[AVAudioRecorder alloc]initWithURL:[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@.%@", [NSHomeDirectory() stringByAppendingString:@"/Documents"], name, extension]] settings:nil error:nil];
#pragma clang diagnostic pop
Run Code Online (Sandbox Code Playgroud)
一种简单的检查方法是使用Show Completions
- 转到方法名称并按Ctrl-Space菜单Editor
>中的 或Show Completions
。将会弹出一个窗口。查找带有(nonnull)
- 这些不能是的条目nil
。例如:
我Ctrl-Space用光标按了[NSString stringWithFormat:...]
。正如您所看到的,很多参数都被标记了(nonnull)
。
当你显式传入nil
你的方法调用时,你就已经发现了问题。如果你传递一个变量,检查它是否是nil
在那个时间。
归档时间: |
|
查看次数: |
11992 次 |
最近记录: |