diff --git a/SGDownload/Classes/SGDownloadTools.m b/SGDownload/Classes/SGDownloadTools.m index 1ebd8b9..409f37e 100644 --- a/SGDownload/Classes/SGDownloadTools.m +++ b/SGDownload/Classes/SGDownloadTools.m @@ -44,7 +44,12 @@ + (NSString *)replacehHomeDirectoryForFilePath:(NSString *)filePath NSError * error; NSRegularExpression * regex = [NSRegularExpression regularExpressionWithPattern:@"(\\w*-){4}(\\w*)" options:0 error:&error]; if (!error) { +#if !defined(TARGET_OS_SIMULATOR) || TARGET_OS_SIMULATOR + NSArray *results =[regex matchesInString:filePath options:NSMatchingReportCompletion range:NSMakeRange(0, filePath.length)]; + NSTextCheckingResult * match = results[1]; +#else NSTextCheckingResult * match = [regex firstMatchInString:filePath options:0 range:NSMakeRange(0, filePath.length)]; +#endif if (match) { NSString * currentName = NSHomeDirectory().lastPathComponent; filePath = [filePath stringByReplacingCharactersInRange:match.range withString:currentName];