-
大小: 92.68MB文件類型: .zip金幣: 2下載: 1 次發布日期: 2021-12-13
- 語言: 其他
- 標簽: Raywenderlic??Architecture??
資源簡介
Raywenderlich 最新系列,iOS12 swift4.2,包括所有源碼
代碼片段和文件信息
#import?“LSNocilla.h“
#import?“LSNSURLHook.h“
#import?“LSStubRequest.h“
#import?“LSHTTPRequestDSLRepresentation.h“
#import?“LSASIHTTPRequestHook.h“
#import?“LSNSURLSessionHook.h“
#import?“LSASIHTTPRequestHook.h“
NSString?*?const?LSUnexpectedRequest?=?@“Unexpected?Request“;
@interface?LSNocilla?()
@property?(nonatomic?strong)?NSMutableArray?*mutableRequests;
@property?(nonatomic?strong)?NSMutableArray?*hooks;
@property?(nonatomic?assign?getter?=?isStarted)?BOOL?started;
-?(void)loadHooks;
-?(void)unloadHooks;
@end
static?LSNocilla?*sharedInstace?=?nil;
@implementation?LSNocilla
+?(LSNocilla?*)sharedInstance?{
????static?dispatch_once_t?onceToken;
????dispatch_once(&onceToken?^{
????????sharedInstace?=?[[self?alloc]?init];
????});
????return?sharedInstace;
}
-?(id)init?{
????self?=?[super?init];
????if?(self)?{
????????_mutableRequests?=?[NSMutableArray?array];
????????_hooks?=?[NSMutableArray?array];
????????[self?registerHook:[[LSNSURLHook?alloc]?init]];
????????if?(NSClassFromString(@“NSURLSession“)?!=?nil)?{
????????????[self?registerHook:[[LSNSURLSessionHook?alloc]?init]];
????????}
????????[self?registerHook:[[LSASIHTTPRequestHook?alloc]?init]];
????}
????return?self;
}
-?(NSArray?*)stubbedRequests?{
????return?[NSArray?arrayWithArray:self.mutableRequests];
}
-?(void)start?{
????if?(!self.isStarted){
????????[self?loadHooks];
????????self.started?=?YES;
????}
}
-?(void)stop?{
????[self?unloadHooks];
????[self?clearStubs];
????self.started?=?NO;
}
-?(void)addStubbedRequest:(LSStubRequest?*)request?{
????NSUInteger?index?=?[self.mutableRequests?indexOfobject:request];
????if?(index?==?NSNotFound)?{
????????[self.mutableRequests?addobject:request];
????????return;
????}
????[self.mutableRequests?replaceobjectAtIndex:index?withobject:request];
}
-?(void)clearStubs?{
????[self.mutableRequests?removeAllobjects];
}
-?(LSStubResponse?*)responseForRequest:(id)actualRequest?{
????NSArray*?requests?=?[LSNocilla?sharedInstance].stubbedRequests;
????for(LSStubRequest?*someStubbedRequest?in?requests)?{
????????if?([someStubbedRequest?matchesRequest:actualRequest])?{
????????????return?someStubbedRequest.response;
????????}
????}
????[NSException?raise:@“NocillaUnexpectedRequest“?format:@“An?unexpected?HTTP?request?was?fired.\n\nUse?this?snippet?to?stub?the?request:\n%@\n“?[[[LSHTTPRequestDSLRepresentation?alloc]?initWithRequest:actualRequest]?description]];
????return?nil;
}
-?(void)registerHook:(LSHTTPClientHook?*)hook?{
????if?(![self?hookWasRegistered:hook])?{
????????[[self?hooks]?addobject:hook];
????}
}
-?(BOOL)hookWasRegistered:(LSHTTPClientHook?*)aHook?{
????for?(LSHTTPClientHook?*hook?in?self.hooks)?{
????????if?([hook?isMemberOfClass:?[aHook?class]])?{
????????????return?YES;
????????}
????}
????return?NO;
}
#pragma?mark?-?Private
-?(void)loadHooks?{
????for?(LSHTTPClientHook?*hook?in?self.hooks)?{
????????[hook?load];
????}
}
-?(void)unloadHooks?{
????for?(LSHTTPClientHook?*hook?in?self.hooks)?{
????????[
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-10-01?10:14??03-example-app\
?????目錄???????????0??2018-10-01?10:14??03-example-app\final\
?????目錄???????????0??2018-10-01?10:14??03-example-app\final\KooberApp\
?????文件?????????104??2018-10-01?10:14??03-example-app\final\KooberApp\Cartfile
?????文件?????????154??2018-10-01?10:14??03-example-app\final\KooberApp\Cartfile.resolved
?????目錄???????????0??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\
?????目錄???????????0??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\
?????目錄???????????0??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\
?????目錄???????????0??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\.github\
?????文件????????1006??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\.github\ISSUE_TEMPLATE.md
?????文件???????????6??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\.ruby-version
?????文件???????????3??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\.swift-version
?????文件????????1099??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\.travis.yml
?????文件???????45078??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\CHANGELOG.md
?????文件?????????132??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\codecov.yml
?????文件????????4549??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\CONTRIBUTING.md
?????目錄???????????0??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\
?????目錄???????????0??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\Demo\
?????目錄???????????0??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\Demo\Kingfisher-Demo\
?????文件????????1518??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\Demo\Kingfisher-Demo\AppDelegate.swift
?????目錄???????????0??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\Demo\Kingfisher-Demo\ba
?????文件????????3929??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\Demo\Kingfisher-Demo\ba
?????文件????????6718??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\Demo\Kingfisher-Demo\ba
?????文件????????1566??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\Demo\Kingfisher-Demo\CollectionViewCell.swift
?????目錄???????????0??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\Demo\Kingfisher-Demo\Images.xcassets\
?????目錄???????????0??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\Demo\Kingfisher-Demo\Images.xcassets\AppIcon.appiconset\
?????文件????????1590??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\Demo\Kingfisher-Demo\Images.xcassets\AppIcon.appiconset\Contents.json
?????文件????????1500??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\Demo\Kingfisher-Demo\Info.plist
?????文件???????10302??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\Demo\Kingfisher-Demo\loader.gif
?????文件????????4557??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\Demo\Kingfisher-Demo\ViewController.swift
?????目錄???????????0??2018-10-01?10:14??03-example-app\final\KooberApp\Carthage\Checkouts\Kingfisher\Demo\Demo\Kingfisher-macOS-Demo\
............此處省略9081個文件信息
評論
共有 條評論