黑马程序员——OC基础之NSLog
2015-12-06 11:59
441 查看
-------
iOS培训、android培训、java培训、期待与您交流! ----------
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
//NSLog和printf使用差异
//1、NSLog 会自动换行 printf 不会
//2、NSLog 会自动输出时间等项目信息 printf 不会
//3、NSLog 参数是一个NSString 对象 printf 是一个字符串常量指针
NSLog(@"Hello, Black!");
printf("Hello, Black!\n");
int a = 5;
float f1 = 2.3f;
double d1 = 3.14;
char ch = 'x';
char *str = "张三丰";
printf("%d,%.2f,%.2f,%c\n",a,f1,d1,ch);
printf("%s\n",str);
NSLog(@"%d,%.2f,%.2f,%c",a,f1,d1,ch);//可以格式化输出
NSLog(@"--->%s",str);//写法错误
//OC用%@输出字符串
NSString *str1 = @"张三丰";
NSLog(@"%@",str1);
//printf("---->%@\n",str1);//不支持
}
return 0;
}
iOS培训、android培训、java培训、期待与您交流! ----------
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
//NSLog和printf使用差异
//1、NSLog 会自动换行 printf 不会
//2、NSLog 会自动输出时间等项目信息 printf 不会
//3、NSLog 参数是一个NSString 对象 printf 是一个字符串常量指针
NSLog(@"Hello, Black!");
printf("Hello, Black!\n");
int a = 5;
float f1 = 2.3f;
double d1 = 3.14;
char ch = 'x';
char *str = "张三丰";
printf("%d,%.2f,%.2f,%c\n",a,f1,d1,ch);
printf("%s\n",str);
NSLog(@"%d,%.2f,%.2f,%c",a,f1,d1,ch);//可以格式化输出
NSLog(@"--->%s",str);//写法错误
//OC用%@输出字符串
NSString *str1 = @"张三丰";
NSLog(@"%@",str1);
//printf("---->%@\n",str1);//不支持
}
return 0;
}
相关文章推荐
- NSLog 格式
- 第三方库CocoaLumberjack的简单使用
- 创建SDK时NSLog的解决办法
- OC中NSLog输出格式
- iOS - NSLog的使用方法
- 如何NSLog Integer类型,帮你消除warning
- nslog格式转换
- 可变参数函数写法
- OC 日志打印
- C与OC
- iOS学习笔记--12 NSLog相关
- iOS NSLog输出
- NSLog输出格式
- iOS开发之使用代码定位性更高的Log
- NSLog的格式
- Objective-c——NSLog
- iOS Development: You're Doing It Wrong
- 自定义NSLog
- NSLog替换的演变
- 【ios自学笔记】OC中log信息的输出方法,包含import、字符串、输出日志等知识点