Using NSLog for debugging

前端 未结 6 2209
暗喜
暗喜 2020-12-16 10:02

I have the following code snippet in my Xcode:

NSString *digit [[sender titlelabel] text];
NSLog([digit]);

I tried to build the application

6条回答
  •  一生所求
    2020-12-16 10:57

    The proper way of using NSLog, as the warning tries to explain, is the use of a formatter, instead of passing in a literal:

    Instead of:

    NSString *digit = [[sender titlelabel] text];
    NSLog(digit);
    

    Use:

    NSString *digit = [[sender titlelabel] text];
    NSLog(@"%@",digit);
    

    It will still work doing that first way, but doing it this way will get rid of the warning.

提交回复
热议问题