-
大小: 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个文件信息
相关资源
- Game Engine Architecture游戏引擎架构.pdf
- UPnP-av-AVArchitecture-v1-中文
- Beyond Software Architecture - Creating and Su
-
em
bedded Deep Learning_ Algorithms Architec - Executable UML: A Foundation for Model-Driven
- Computer Organization and Architecture 第8版答
- Software Architecture in Practice(3rd) 无水
- arm v8 体系架构 官方手册
- 高级FPGA设计结构、实现和优化(英文
- Computer Architecture A Quantitative Approach
- App Architecture
- automotive electronic architectures of integra
- The Architecture of Open Source Applications 2
- High Efficiency Video Coding (Hevc) Algori
- objccn-app-architecture,pdf epub mobi App架构
- Patterns of Enterprise Application Architectur
- App Architecture: iOS Application Design Patte
- Computer Architecture: A Quantitative approach
- Fast Data Architectures For Streaming Applicat
- Patterns in Network Architecture A Return to F
- [book]Network Processors - Architecture Progra
- ARM Architecture Reference Manual
- game architecture and design
- Designing for Cisco Network Service Architectu
- Network Processors Architecture Programming an
- Computer Organization and Architecture Designi
- SCSI Architecture Model - 5 (SAM-5)
- ZebOS Architecture Developer Guide
- Essentials of Computer Architecture 2nd Editio
- A Comprehensive Guide to Digital Electronics a
评论
共有 条评论