Xcode 8 Does not display the whole NSLog output

后端 未结 2 1959
-上瘾入骨i
-上瘾入骨i 2021-02-07 05:49

After upgrading to Xcode 8 GM today i noticed that NSLog isn\'t printing the whole log-message to the console. This is especially noticeable when working against an API that dow

2条回答
  •  礼貌的吻别
    2021-02-07 06:17

    You can use this method. Split every 800 chars. Or can be set. NSLOG I think truncate every 1000 chars. If string is less than 800 will use a simple NSLog. This is useful for Json long strings and uses the console. printf uses Xcode debug window not the console.

    -(void) JSLog:(NSString*)logString{
    
            int stepLog = 800;
            NSInteger strLen = [@([logString length]) integerValue];
            NSInteger countInt = strLen / stepLog;
    
            if (strLen > stepLog) {
            for (int i=1; i <= countInt; i++) {
                NSString *character = [logString substringWithRange:NSMakeRange((i*stepLog)-stepLog, stepLog)];
                NSLog(@"%@", character);
    
            }
            NSString *character = [logString substringWithRange:NSMakeRange((countInt*stepLog), strLen-(countInt*stepLog))];
            NSLog(@"%@", character);
            } else {
    
            NSLog(@"%@", logString);
            }
    
    }
    

提交回复
热议问题