简体   繁体   中英

Filtering console output containing multiline strings in Xcode

I'm printing JSON data that spans multiple lines to the console. I'm prefixing all my messages with a tag and then filtering by that tag to keep things relevant. So my messages look like this with no filter:

TAG: {
"key1": "value1",
"key2": "value2",
... 
}

When I filter by TAG, I only see the first line because as far as I can tell, Xcode is just checking line by line instead checking by message.

TAG: {

How can I make Xcode output all the lines in the JSON? Is there a better way than writing my own print function that splits by \\n and prefixes each line with TAG? This might not even work because the values might have a \\n internally.

You can use .description property while printing. Here is an example print(yourObject.description) It prints everything in one line and while doing a filter, you will be able to see everything.

This worked for me. Hope this helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM