ios列印日誌的類,方法,及行號

2021-07-04 05:06:34 字數 524 閱讀 2716

//列印檔案,方法,行號

#ifdef debug

# define debuglog(fmt, ...) nslog((@"\n[檔名:%s]\n""[函式名:%s]\n""[行號:%d] \n" fmt), __file__, __function__, __line__, ##__va_args__);

#else

# define debuglog(...);

#endif

如果要列印類,方法及行號

#ifdef debug

# define debuglog(fmt, ...) nslog((@" 方法:%s 行號:%d 日誌內容:" fmt), __function__, __line__, ##__va_args__);

#else

# define debuglog(...);

#endif

把以上**放到標頭檔案或pch檔案即可列印詳細資訊

iOS日誌列印存貯到txt檔案及沙盒檔案操作

在我們開發中過程中有時候會有這樣的場景,需要脫離連線除錯 但是又看不見控制台的log,所以將log存到文字中,除錯過程全部記錄下來,隨時可以看。存貯 class func logwithtag tag string let datalog try nsmutablestring contentsof...

iOS反射 2 類方法的反射

1.nsobject常用方法 類別判斷,也可以說是動態方法 objc view plain copy student stu student alloc init autorelease iskindofclass判斷物件是否屬於某個類 或者 子類 if stu iskindofclass pers...

Date類 Calendar類的常用方法及運用

需求 1.根據生日計算年齡 2.獲取輸入日期的星期幾 3.獲取輸入日期的當月第一天 4.獲取輸入日期的當月最後一天 5.判斷該年是否是閏年 6.根據整型數表示的年月日,生成日期型別格式 public class birthday nowtime 獲取輸入日期的當月第一天 int firstday c...