How to print something to the console in Xcode?

后端 未结 6 1137
逝去的感伤
逝去的感伤 2021-02-06 20:45

How do you print something to the console of Xcode, and is it possible to view the Xcode console from the app itself?

Thanks!

6条回答
  •  自闭症患者
    2021-02-06 21:13

    3 ways to do this:

    In C Language (Command Line Tool) Works with Objective C, too:

    printf("Hello World");
    

    In Objective C:

    NSLog(@"Hello, World!");
    

    In Objective C with variables:

    NSString * myString = @"Hello World";
    NSLog(@"%@", myString);
    

    In the code with variables, the variable created with class, NSString was outputted be NSLog. The %@ represents text as a variable.

提交回复
热议问题