IOS 文件下载器-MCDownloadManager

我们用AFNetworking小试牛刀,写一个简单的下载器来演示功能。

前言

为什么AFNetworking能够成为顶级框架?我们究竟该如何领悟它的精髓所在?这都是很难的问题。安全,高效,流畅,这3个特性缺一不可。假如我们要封装一个通用的网络框架,提供一个文件下载器是很有必要的。按照 管理编程原则 ,这个下载管理器应该管理所有的下载任务和依据。

这是一个简单的下载器,只为了功能演示

下载器提供的功能

  1. 根据一个url下载文件 我们下载一个文件,最重要的就是url,因此我们应该把这个url作为下载的唯一标识。
  2. 提供下载进度 为了增加用户体验,往往在下载文件的同时,展示一个下载进度告诉用户当前的下载情况,有的人喜欢使用bytesWriten/totalBytesWriten/totalExpectedBytesWriten,但AFNetworking中使用的都是NSProgress。因此,我们也采用NSProgress表示进度。
  3. 下载完成的回调 通知下载完成的方式有通知/代理/Block,我们采用的是Block。
  4. 下载失败的回调 同上
  5. 根据url获取下载对象 我们把下载的对象包装成了MCDownloadReceipt,我能够在MCDownloadReceipt对象中获取到我们需要的所有内容。
  6. 回复/暂停/取消 下载任务 这些功能,我们使用协议来实现。
  7. 下载限制和顺序 我们能够自定义同时下载文件的个数,默认为4个。能够自定义等待队列中的任务是先进先出还是后进先出。

设计思路

写一个下载器,一定需要一个对象来描述下载的文件。在这个下载器中,我们使用MCDownloadReceipt。既然是一个信息的载体,那么从设计角度来说,我们应该使用它来存储跟文件相关的内容,不应该让他完成其他更多的事情,比如说开始,暂停等等。

MCDownloadReceipt使用归档进行本地化存储。

核心下载使用NSURLSession实现,下边我们会介绍详情。

MCDownloadReceipt

MCDownloadReceipt的主要功能是用于记录下载信息。即使下载未完成,也能在MCDownloadReceipt的filePath路径下找个这个文件。

我们先来看看暴露出来的头文件信息:

  • NSString *url 作为MCDownloadReceipt的唯一标识。
  • NSString *filePath MCDownloadReceipt的文件索引。
  • NSString *filename MCDownloadReceipt的文件名,命名规则为:把url进行MD5编码后作为文件名,url中如果有后缀,就拼接后缀。
  • MCDownloadState state MCDownloadReceipt的状态
    • MCDownloadStateNone,
    • MCDownloadStateWillResume,
    • MCDownloadStateDownloading,
    • MCDownloadStateSuspened,
    • MCDownloadStateCompleted,
    • MCDownloadStateFailed
  • long long totalBytesWritten 总共写入的数据的大小
  • totalBytesExpectedToWrite 文件总大小
  • NSOutputStream *stream 用于把数据写入到路径中
1.获取filename

通常我们把文件的下载URL进行MD5编码后在拼接上后缀名来作为本地文件的名称。

把一个字符串转为MD5字符串:

static NSString * getMD5String(NSString *str) {
    
    if (str == nil) return nil;
    
    const char *cstring = str.UTF8String;
    unsigned char bytes[CC_MD5_DIGEST_LENGTH];
    CC_MD5(cstring, (CC_LONG)strlen(cstring), bytes);
    
    NSMutableString *md5String = [NSMutableString string];
    for (int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
        [md5String appendFormat:@"%02x", bytes[i]];
    }
    return md5String;
}

拼接名称:

- (NSString *)filename {
    if (_filename == nil) {
        NSString *pathExtension = self.url.pathExtension;
        if (pathExtension.length) {
            _filename = [NSString stringWithFormat:@"%@.%@", getMD5String(self.url), pathExtension];
        } else {
            _filename = getMD5String(self.url);
        }
    }
    return _filename;
}
2.获取filePath

首先我们要获取一个缓存的路径:

NSString * const MCDownloadCacheFolderName = @"MCDownloadCache";

static NSString * cacheFolder() {
    NSFileManager *filemgr = [NSFileManager defaultManager];
    static NSString *cacheFolder;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if (!cacheFolder) {
            NSString *cacheDir = NSHomeDirectory();
            cacheFolder = [cacheDir stringByAppendingPathComponent:MCDownloadCacheFolderName];
        }
        NSError *error = nil;
        if(![filemgr createDirectoryAtPath:cacheFolder withIntermediateDirectories:YES attributes:nil error:&error]) {
            NSLog(@"Failed to create cache directory at %@", cacheFolder);
            cacheFolder = nil;
        }
    });
    
    return cacheFolder;
}

拼接路径和文件名:

- (NSString *)filePath {

    NSString *path = [cacheFolder() stringByAppendingPathComponent:self.filename];
    if (![path isEqualToString:_filePath] ) {
        if (_filePath && ![[NSFileManager defaultManager] fileExistsAtPath:_filePath]) {
            NSString *dir = [_filePath stringByDeletingLastPathComponent];
            [[NSFileManager defaultManager] createDirectoryAtPath:dir withIntermediateDirectories:YES attributes:nil error:nil];
        }
        _filePath = path;
    }
    
    return _filePath;
}
3.获取文件的大小

获取某个路径下文件的大小:

static unsigned long long fileSizeForPath(NSString *path) {
    
    signed long long fileSize = 0;
    NSFileManager *fileManager = [NSFileManager defaultManager];
    if ([fileManager fileExistsAtPath:path]) {
        NSError *error = nil;
        NSDictionary *fileDict = [fileManager attributesOfItemAtPath:path error:&error];
        if (!error && fileDict) {
            fileSize = [fileDict fileSize];
        }
    }
    return fileSize;
}

获取本对象的文件大小:

- (long long)totalBytesWritten {
    
    return fileSizeForPath(self.filePath);
}
4.初始化stream
- (NSOutputStream *)stream
{
    if (_stream == nil) {
        _stream = [NSOutputStream outputStreamToFileAtPath:self.filePath append:YES];
    }
    return _stream;
}
5.设置progress
- (NSProgress *)progress {
    if (_progress == nil) {
        _progress = [[NSProgress alloc] initWithParent:nil userInfo:nil];
    }
    _progress.totalUnitCount = self.totalBytesExpectedToWrite;
    _progress.completedUnitCount = self.totalBytesWritten;
    return _progress;
}
6.初始化和归档
- (instancetype)initWithURL:(NSString *)url {
    if (self = [self init]) {
   
        self.url = url;
        self.totalBytesExpectedToWrite = 1;
    }
    return self;
}

#pragma mark - NSCoding
- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:self.url forKey:NSStringFromSelector(@selector(url))];
    [aCoder encodeObject:self.filePath forKey:NSStringFromSelector(@selector(filePath))];
    [aCoder encodeObject:@(self.state) forKey:NSStringFromSelector(@selector(state))];
    [aCoder encodeObject:self.filename forKey:NSStringFromSelector(@selector(filename))];
    [aCoder encodeObject:@(self.totalBytesWritten) forKey:NSStringFromSelector(@selector(totalBytesWritten))];
    [aCoder encodeObject:@(self.totalBytesExpectedToWrite) forKey:NSStringFromSelector(@selector(totalBytesExpectedToWrite))];

}

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];
    if (self) {
        self.url = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(url))];
        self.filePath = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(filePath))];
        self.state = [[aDecoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(state))] unsignedIntegerValue];
        self.filename = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(filename))];
        self.totalBytesWritten = [[aDecoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(totalBytesWritten))] unsignedIntegerValue];
        self.totalBytesExpectedToWrite = [[aDecoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(totalBytesExpectedToWrite))] unsignedIntegerValue];

    }
    return self;
}

MCDownloadControlDelegate

是这样的,如果我们要给某个对象扩展一类的功能或者方法,那么我们最好使用协议。在AFNetworking的AFURLResponseSerialization和AFURLRequestSerialization就是最好的例子。

@protocol MCDownloadControlDelegate <NSObject>

- (void)resumeWithURL:(NSString * _Nonnull)url;
- (void)resumeWithDownloadReceipt:(MCDownloadReceipt * _Nonnull)receipt;

- (void)suspendWithURL:(NSString * _Nonnull)url;
- (void)suspendWithDownloadReceipt:(MCDownloadReceipt * _Nonnull)receipt;

- (void)removeWithURL:(NSString * _Nonnull)url;
- (void)removeWithDownloadReceipt:(MCDownloadReceipt * _Nonnull)receipt;

@end

实现部分:

#pragma mark - MCDownloadControlDelegate

- (void)resumeWithURL:(NSString *)url {
    
    if (url == nil) return;
    
    MCDownloadReceipt *receipt = [self downloadReceiptForURL:url];
    [self resumeWithDownloadReceipt:receipt];
    
}
- (void)resumeWithDownloadReceipt:(MCDownloadReceipt *)receipt {
    
    if ([self isActiveRequestCountBelowMaximumLimit]) {
        [self startTask:self.tasks[receipt.url]];
    }else {
        receipt.state = MCDownloadStateWillResume;
        [self saveReceipts:self.allDownloadReceipts];
        [self enqueueTask:self.tasks[receipt.url]];
    }
}

- (void)suspendAll {
    
    for (NSURLSessionDownloadTask *task in self.queuedTasks) {
        [task suspend];
        MCDownloadReceipt *receipt = [self downloadReceiptForURL:task.taskDescription];
        receipt.state = MCDownloadStateSuspened;
    }

    [self saveReceipts:self.allDownloadReceipts];
    
}
-(void)suspendWithURL:(NSString *)url {
    
     if (url == nil) return;
    
    MCDownloadReceipt *receipt = [self downloadReceiptForURL:url];
    [self suspendWithDownloadReceipt:receipt];
    
}
- (void)suspendWithDownloadReceipt:(MCDownloadReceipt *)receipt {
    
    [self updateReceiptWithURL:receipt.url state:MCDownloadStateSuspened];
    NSURLSessionDataTask *task = self.tasks[receipt.url];
    if (task) {
        [task suspend];
    }
}


- (void)removeWithURL:(NSString *)url {
    
    if (url == nil) return;
    
    MCDownloadReceipt *receipt = [self downloadReceiptForURL:url];
    [self removeWithDownloadReceipt:receipt];
    
}
- (void)removeWithDownloadReceipt:(MCDownloadReceipt *)receipt {
    
    NSURLSessionDataTask *task = self.tasks[receipt.url];
    if (task) {
        [task cancel];
    }
    
    [self.queuedTasks removeObject:task];
    [self safelyRemoveTaskWithURLIdentifier:receipt.url];
    
    [self.allDownloadReceipts removeObject:receipt];
    
    [self saveReceipts:self.allDownloadReceipts];
    
    NSFileManager *fileManager = [NSFileManager defaultManager];
    [fileManager removeItemAtPath:receipt.filePath error:nil];

}

MCDownloadManager

初始化MCDownloadManager跟AFNetworkingAFImageDownloader的初始化很像,做一些网络配置。参数配置。我们规定下载任务的创建都放在一个专有的同步队列中完成。我们还要监听applicationWillTerminateapplicationDidReceiveMemoryWarning这两个通知,并在通知方法中,暂停多有的下载任务。

初始化示例代码:

+ (NSURLSessionConfiguration *)defaultURLSessionConfiguration {
    NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
    
    configuration.HTTPShouldSetCookies = YES;
    configuration.HTTPShouldUsePipelining = NO;
    configuration.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
    configuration.allowsCellularAccess = YES;
    configuration.timeoutIntervalForRequest = 60.0;
   
    return configuration;
}


- (instancetype)init {
    

    NSURLSessionConfiguration *defaultConfiguration = [self.class defaultURLSessionConfiguration];
  
    NSOperationQueue *queue = [[NSOperationQueue alloc] init];
    queue.maxConcurrentOperationCount = 1;
    NSURLSession *session = [NSURLSession sessionWithConfiguration:defaultConfiguration delegate:self delegateQueue:queue];
    
    return [self initWithSession:session
                 downloadPrioritization:MCDownloadPrioritizationFIFO
                 maximumActiveDownloads:4 ];
}


- (instancetype)initWithSession:(NSURLSession *)session downloadPrioritization:(MCDownloadPrioritization)downloadPrioritization maximumActiveDownloads:(NSInteger)maximumActiveDownloads {
    if (self = [super init]) {
        
        self.session = session;
        self.downloadPrioritizaton = downloadPrioritization;
        self.maximumActiveDownloads = maximumActiveDownloads;
        
        self.queuedTasks = [[NSMutableArray alloc] init];
        self.tasks = [[NSMutableDictionary alloc] init];
        self.activeRequestCount = 0;
        

        NSString *name = [NSString stringWithFormat:@"com.mc.downloadManager.synchronizationqueue-%@", [[NSUUID UUID] UUIDString]];
        self.synchronizationQueue = dispatch_queue_create([name cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_SERIAL);

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:UIApplicationWillTerminateNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidReceiveMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
        
    }
    
    return self;
}

+ (instancetype)defaultInstance {
    static MCDownloadManager *sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedInstance = [[self alloc] init];
    });
    return sharedInstance;
}

初始化完成后,我们需要在MCDownloadManager中拿到所有的下载的数据,以及能够保存这些数据到本地。

示例代码:

- (NSMutableArray *)allDownloadReceipts {
    if (_allDownloadReceipts == nil) {
         NSArray *receipts = [NSKeyedUnarchiver unarchiveObjectWithFile:LocalReceiptsPath()];
        _allDownloadReceipts = receipts != nil ? receipts.mutableCopy : [NSMutableArray array];
    }
    return _allDownloadReceipts;
}

- (void)saveReceipts:(NSArray <MCDownloadReceipt *>*)receipts {
    [NSKeyedArchiver archiveRootObject:receipts toFile:LocalReceiptsPath()];
}

下载的核心方法:

- (MCDownloadReceipt *)downloadFileWithURL:(NSString *)url
                                         progress:(void (^)(NSProgress * _Nonnull,MCDownloadReceipt *receipt))downloadProgressBlock
                                         destination:(NSURL *  (^)(NSURL * _Nonnull, NSURLResponse * _Nonnull))destination
                                          success:(nullable void (^)(NSURLRequest * _Nullable, NSHTTPURLResponse * _Nullable, NSURL * _Nonnull))success
                                          failure:(nullable void (^)(NSURLRequest * _Nullable, NSHTTPURLResponse * _Nullable, NSError * _Nonnull))failure {
 
   __block MCDownloadReceipt *receipt = [self downloadReceiptForURL:url];
    
    dispatch_sync(self.synchronizationQueue, ^{
        NSString *URLIdentifier = url;
        if (URLIdentifier == nil) {
            if (failure) {
                NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadURL userInfo:nil];
                dispatch_async(dispatch_get_main_queue(), ^{
                    failure(nil, nil, error);
                });
            }
            return;
        }

        receipt.successBlock = success;
        receipt.failureBlock = failure;
        receipt.progressBlock = downloadProgressBlock;
        
        if (receipt.state == MCDownloadStateCompleted) {
            dispatch_async(dispatch_get_main_queue(), ^{
                if (receipt.successBlock) {
                    receipt.successBlock(nil,nil,[NSURL URLWithString:receipt.url]);
                }
            });
            return ;
        }
        
        if (receipt.state == MCDownloadStateDownloading) {
            dispatch_async(dispatch_get_main_queue(), ^{
                if (receipt.progressBlock) {
                    receipt.progressBlock(receipt.progress,receipt);
                }
            });
            return ;
        }

        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:receipt.url]];
        NSString *range = [NSString stringWithFormat:@"bytes=%zd-", receipt.totalBytesWritten];
        [request setValue:range forHTTPHeaderField:@"Range"];
        
        NSURLSessionDataTask *task = [self.session dataTaskWithRequest:request];
        task.taskDescription = receipt.url;
        self.tasks[receipt.url] = task;
        [self.queuedTasks addObject:task];
        
        [self resumeWithURL:receipt.url];
        
        
        });
    return receipt;
}

--

- (NSURLSessionDownloadTask*)safelyRemoveTaskWithURLIdentifier:(NSString *)URLIdentifier {
    __block NSURLSessionDownloadTask *task = nil;
    dispatch_sync(self.synchronizationQueue, ^{
        task = [self removeTaskWithURLIdentifier:URLIdentifier];
    });
    return task;
}

//This method should only be called from safely within the synchronizationQueue
- (NSURLSessionDownloadTask *)removeTaskWithURLIdentifier:(NSString *)URLIdentifier {
    NSURLSessionDownloadTask *task = self.tasks[URLIdentifier];
    [self.tasks removeObjectForKey:URLIdentifier];
    return task;
}

- (void)safelyDecrementActiveTaskCount {
    dispatch_sync(self.synchronizationQueue, ^{
        if (self.activeRequestCount > 0) {
            self.activeRequestCount -= 1;
        }
    });
}

- (void)safelyStartNextTaskIfNecessary {
    dispatch_sync(self.synchronizationQueue, ^{
        if ([self isActiveRequestCountBelowMaximumLimit]) {
            while (self.queuedTasks.count > 0) {
                NSURLSessionDownloadTask *task = [self dequeueTask];
                MCDownloadReceipt *receipt = [self downloadReceiptForURL:task.taskDescription];
                if (task.state == NSURLSessionTaskStateSuspended && receipt.state == MCDownloadStateWillResume) {
                    [self startTask:task];
                    break;
                }
            }
        }
    });
}


- (void)startTask:(NSURLSessionDownloadTask *)task {
    [task resume];
    ++self.activeRequestCount;
    [self updateReceiptWithURL:task.taskDescription state:MCDownloadStateDownloading];
}

- (void)enqueueTask:(NSURLSessionDownloadTask *)task {
    switch (self.downloadPrioritizaton) {
        case MCDownloadPrioritizationFIFO:  //
            [self.queuedTasks addObject:task];
            break;
        case MCDownloadPrioritizationLIFO:  //
            [self.queuedTasks insertObject:task atIndex:0];
            break;
    }
}

- (NSURLSessionDownloadTask *)dequeueTask {
    NSURLSessionDownloadTask *task = nil;
    task = [self.queuedTasks firstObject];
    [self.queuedTasks removeObject:task];
    return task;
}

- (BOOL)isActiveRequestCountBelowMaximumLimit {
    return self.activeRequestCount < self.maximumActiveDownloads;
}

根据URL获取receipt对象:

- (MCDownloadReceipt *)downloadReceiptForURL:(NSString *)url {
    
    if (url == nil) return nil;
    for (MCDownloadReceipt *receipt in self.allDownloadReceipts) {
        if ([receipt.url isEqualToString:url]) {
            return receipt;
        }
    }
    MCDownloadReceipt *receipt = [[MCDownloadReceipt alloc] initWithURL:url];
    receipt.state = MCDownloadStateNone;
    receipt.totalBytesExpectedToWrite = 1;
    [self.allDownloadReceipts addObject:receipt];
    [self saveReceipts:self.allDownloadReceipts];
    return receipt;
}

NSURLSessionDataDelegate:

在接到响应后,保存totalBytesExpectedToWrite和state

- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSHTTPURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler
{
    MCDownloadReceipt *receipt = [self downloadReceiptForURL:dataTask.taskDescription];
    receipt.totalBytesExpectedToWrite = dataTask.countOfBytesExpectedToReceive;
    receipt.state = MCDownloadStateDownloading;
    @synchronized (self) {
        [self saveReceipts:self.allDownloadReceipts];
    }
   
    [receipt.stream open];
    
    completionHandler(NSURLSessionResponseAllow);
}

在接收到数据后,写入文件并且调用progressBlock

- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data
{
    MCDownloadReceipt *receipt = [self downloadReceiptForURL:dataTask.taskDescription];
    
    [receipt.stream write:data.bytes maxLength:data.length];

    receipt.progress.totalUnitCount = receipt.totalBytesExpectedToWrite;
    receipt.progress.completedUnitCount = receipt.totalBytesWritten;
   dispatch_async(dispatch_get_main_queue(), ^{
       if (receipt.progressBlock) {
           receipt.progressBlock(receipt.progress,receipt);
       }
   });

}

下载完成后

- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
{
    MCDownloadReceipt *receipt = [self downloadReceiptForURL:task.taskDescription];
    [receipt.stream close];
    receipt.stream = nil;

    if (error) {
        receipt.state = MCDownloadStateFailed;
        dispatch_async(dispatch_get_main_queue(), ^{
            if (receipt.failureBlock) {
                receipt.failureBlock(task.originalRequest,(NSHTTPURLResponse *)task.response,error);
            }
        });
    }else {
        receipt.state = MCDownloadStateCompleted;
        dispatch_async(dispatch_get_main_queue(), ^{
            if (receipt.successBlock) {
                receipt.successBlock(task.originalRequest,(NSHTTPURLResponse *)task.response,task.originalRequest.URL);
            }
        });
    }
    @synchronized (self) {
        [self saveReceipts:self.allDownloadReceipts];
    }
    [self safelyDecrementActiveTaskCount];
    [self safelyStartNextTaskIfNecessary];
    
}

总结

这个下载器就介绍到这里了,可以在https://github.com/agelessman/MCDownloadManager.git下载demo。如发现任何问题或改进意见,可以留言,我会尽力完成。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,590评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 86,808评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,151评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,779评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,773评论 5 367
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,656评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,022评论 3 398
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,678评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 41,038评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,659评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,756评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,411评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,005评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,973评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,203评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,053评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,495评论 2 343

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,596评论 18 139
  • *面试心声:其实这些题本人都没怎么背,但是在上海 两周半 面了大约10家 收到差不多3个offer,总结起来就是把...
    Dove_iOS阅读 27,121评论 29 470
  • 218.241.181.202 wxhl60 123456 192.168.10.253 wxhl66 wxhl6...
    CYC666阅读 1,361评论 0 6
  • iOS开发系列--网络开发 概览 大部分应用程序都或多或少会牵扯到网络开发,例如说新浪微博、微信等,这些应用本身可...
    lichengjin阅读 3,637评论 2 7
  • 我想我找到了一直困惑我的问题。人活着的意义何在? 我认为是,享受。 阿甘正传中的一句经典台词,life ...
    yologh阅读 341评论 0 1