格式不是字符串文字

JAL*_*JAL 1 ios

我将不胜感激,了解如何重写这行代码以消除编译器警告.代码是:

if (string == nil)
        [NSException raise:NSInvalidArgumentException format:nil];
Run Code Online (Sandbox Code Playgroud)

警告是:

Format not a string literal and no format arguments.
Run Code Online (Sandbox Code Playgroud)

我找到了与NSLog有关的答案,但没有找到NSException.

JAL

ugh*_*fhw 6

该错误适用于任何需要格式字符串的内容.你只需要更换nil@"",如:

[NSException raise:NSInvalidArgumentException format:@""];
Run Code Online (Sandbox Code Playgroud)