Using NSLog for debugging

前端 未结 6 2218
暗喜
暗喜 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:39

    type : BOOL DATA (YES/NO) OR(1/0)

    BOOL dtBool = 0; 
    

    OR

    BOOL dtBool = NO;
    NSLog(dtBool ? @"Yes" : @"No");
    

    OUTPUT : NO

    type : Long

    long aLong = 2015;
    NSLog(@"Display Long: %ld”, aLong);
    

    OUTPUT : Display Long: 2015

    long long veryLong = 20152015;
    NSLog(@"Display very Long: %lld", veryLong);
    

    OUTPUT : Display very Long: 20152015

    type : String

    NSString *aString = @"A string";
    NSLog(@"Display string: %@", aString);
    

    OUTPUT : Display String: a String

    type : Float

    float aFloat = 5.34245;
    NSLog(@"Display Float: %F", aFloat);
    

    OUTPUT : isplay Float: 5.342450

    type : Integer

    int aInteger = 3;    
    NSLog(@"Display Integer: %i", aInteger);
    

    OUTPUT : Display Integer: 3

    NSLog(@"\nDisplay String: %@ \n\n Display Float: %f \n\n Display Integer: %i", aString, aFloat, aInteger);
    

    OUTPUT : String: a String

    Display Float: 5.342450

    Display Integer: 3

    http://luterr.blogspot.sg/2015/04/example-code-nslog-console-commands-to.html

提交回复
热议问题