用程式獲取crash日誌
第一步:新建乙個繼承自nsobject的類(xcode新建乙個空專案過程略),取名字catchcrash,在h和m檔案中寫下:
.h檔案
#import
<foundation/foundation.h
>
@inte***ce catchcrash : nsobject
void uncaughtexceptionhandler(n***ception *exception);
@end
.m檔案
#import "catchcrash.h"
@implementation catchcrash
void uncaughtexceptionhandler(n***ception *exception)
@end
第二步:新增乙個繼承自uiviewcontroller的類,取名字為testviewcontroller。
#import "catchcrash.h"
#import "testviewcontroller.h"
第四部:在testviewcontroller的xib上面新增乙個按鈕並給其新增乙個單擊事件,testviewcontroller.m檔案中有如下**:
#import "testviewcontroller.h"
@inte***ce testviewcontroller ()
@end
@implementation testviewcontroller
- (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil
return self;
}
- (void)viewdidload
- (void)didreceivememorywarning
#pragma mark - 單擊事件
#pragma mark - custom method
- (void) killmemory
} @end
執行**:可以看到閃退,匯出error日誌,我們可以看到:
exception reason:nsrangeexception
<span
style
="color:#ff0000;"
>exception name:*** -[__nsarrayi objectatindex:]: index 1 beyond bounds for empty array
span>
exception stack:(
0 corefoundation 0x2f2edfeb<redacted>+ 154
1 libobjc.a.dylib 0x39b66ccf objc_exception_throw + 38
2 corefoundation 0x2f224a89<redacted>+ 176
<span
style
="color:#ff0000;"
>span>
4 uikit 0x31b3f057<redacted>+ 90
5 uikit 0x31b3eff7<redacted>+ 30
6 uikit 0x31b3efd1<redacted>+ 44
7 uikit 0x31b2a737<redacted>+ 374
8 uikit 0x31b3ea4f<redacted>+ 590
9 uikit 0x31b3e721<redacted>+ 528
10 uikit 0x31b396eb<redacted>+ 758
11 uikit 0x31b0e8ed<redacted>+ 196
12 uikit 0x31b0cf97<redacted>+ 7102
13 corefoundation 0x2f2b925b<redacted>+ 14
14 corefoundation 0x2f2b872b<redacted>+ 206
15 corefoundation 0x2f2b6f1f<redacted>+ 622
16 corefoundation 0x2f221f0f cfrunlooprunspecific + 522
17 corefoundation 0x2f221cf3 cfrunloopruninmode + 106
18 graphicsservices 0x3417a663 gseventrunmodal + 138
20 testcrash 0x000e810d main + 116
21 libdyld.dylib 0x3a073ab7<redacted>+ 2 )
AFNpost請求上傳伺服器
afn post的向伺服器提交資料 申明返回的結果是json型別 manager.responseserializer afjsonresponseserializer serializer 申明請求的資料是json型別 manager.requestserializer afjsonrequest...
C 上傳FTP伺服器
using system using system.collections.generic using system.componentmodel using system.data using system.drawing using system.linq using system.text u...
向伺服器上傳檔案
模擬form表單 前端 var formdata new formdata 自帶的函式 通過ajax上傳 ajax handlemodifysucc function data 後端 controller層 獲取前端換過來的資料 const modifycompany req,res req.bod...