Xcode 7 Null is passed to the called party, which requires a non-empty argument

i updated xcode 7 and gave this error

Zero passed to the called party, which requires a non-empty argument

_recorder = [[AVAudioRecorder alloc]initWithURL:[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@.%@", [NSHomeDirectory() stringByAppendingString:@"/Documents"], name, extension]] settings:nil error:nil]; 
+7
ios xcode
source share
2 answers

If you are worried about warnings, you can come to terms with 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 
+25
source share

An easy way to check is to use Show Completions - go to the method name and press Ctrl-Space or in the Editor > Show Completions menu. A window will appear. Look for entries with (nonnull) - they should not be nil . For example:

(nonnull) sample popup

I pressed Ctrl-Space with the cursor in [NSString stringWithFormat:...] . As you can see, many arguments are marked (nonnull) .

When you explicitly pass nil in the method call, you have already found the problem. If you pass the variable, check if there is nil at this time.

+2
source share

All Articles