i updated xcode 7 and gives this error
Null passed to a callee that requires a non-null argument
_recorder = [[AVAudioRecorder alloc]initWithURL:[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@.%@", [NSHomeDirectory() stringByAppendingString:@"/Documents"], name, extension]] settings:nil error:nil];
If what bothers you is the warnings, you can supress that using this -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
An easy way to check is to use Show Completions
- go to a method name and press Ctrl-Space or in the menu Editor
> Show Completions
. A window will pop up. Look for entries with (nonnull)
- these must not be nil
. For example:
I pressed Ctrl-Space with the cursor in [NSString stringWithFormat:...]
. As you can see a lot of arguments are marked (nonnull)
.
When you explicitly pass nil
in your method call, you already found the problem. If you pass a variable, check whether that is nil
at that time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With