ZYCTool.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. //
  2. // ZYCTool.m
  3. // ttt
  4. //
  5. // Created by 张毅成 on 2018/5/14.
  6. // Copyright © 2018年 张毅成. All rights reserved.
  7. //
  8. #import "ZYCTool.h"
  9. #import <AVFoundation/AVCaptureDevice.h>
  10. #import <AVFoundation/AVMediaFormat.h>
  11. #import <Photos/PHPhotoLibrary.h>
  12. @implementation ZYCTool
  13. + (void)alertControllerOneButtonWithTitle:(NSString *)title message:(NSString *)message target:(UIViewController *)viewController defaultButtonTitle:(NSString *)defaultButtonTitle defaultAction:(returnNotarize)defaultAction {
  14. if (defaultButtonTitle.length == 0) {
  15. defaultButtonTitle = @"确认";
  16. }
  17. if (title.length == 0) {
  18. title = @"";
  19. }
  20. if (message.length == 0) {
  21. message = @"";
  22. }
  23. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
  24. UIAlertAction *defaultA = [UIAlertAction actionWithTitle:defaultButtonTitle style:0 handler:^(UIAlertAction *actoin){
  25. if (defaultAction) {
  26. defaultAction();
  27. }
  28. [alertController dismissViewControllerAnimated:true completion:^{}];
  29. }];
  30. [alertController addAction:defaultA];
  31. UIImpactFeedbackGenerator *generator = [[UIImpactFeedbackGenerator alloc] initWithStyle: UIImpactFeedbackStyleLight];
  32. [generator prepare];
  33. [generator impactOccurred];
  34. [viewController presentViewController:alertController animated:YES completion:nil];
  35. }
  36. + (void)alertControllerTwoButtonWithTitle:(NSString *)title message:(NSString *)message target:(UIViewController *)viewController notarizeButtonTitle:(NSString *)notarizeButtonTitle cancelButtonTitle:(NSString *)cancelButtonTitle notarizeAction:(returnNotarize)notarize cancelAction:(returnCancel)cancel {
  37. if (cancelButtonTitle.length == 0) {
  38. cancelButtonTitle = @"取消";
  39. }
  40. if (notarizeButtonTitle.length == 0) {
  41. notarizeButtonTitle = @"确认";
  42. }
  43. if (title.length == 0) {
  44. title = @"";
  45. }
  46. if (message.length == 0) {
  47. message = @"";
  48. }
  49. UIAlertController *alertController = [UIAlertController alertControllerWithTitle: title message:message preferredStyle:UIAlertControllerStyleAlert];
  50. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction *acton){
  51. if (cancel) {
  52. cancel();
  53. }
  54. [alertController dismissViewControllerAnimated:true completion:^{}];
  55. }];
  56. UIAlertAction *notarizeAction = [UIAlertAction actionWithTitle:notarizeButtonTitle style:0 handler:^(UIAlertAction *action){
  57. if (notarize) {
  58. notarize();
  59. }
  60. [alertController dismissViewControllerAnimated:true completion:^{}];
  61. }];
  62. [alertController addAction:cancelAction];
  63. [alertController addAction:notarizeAction];
  64. UIImpactFeedbackGenerator *generator = [[UIImpactFeedbackGenerator alloc] initWithStyle: UIImpactFeedbackStyleLight];
  65. [generator prepare];
  66. [generator impactOccurred];
  67. [viewController presentViewController: alertController animated:YES completion:nil];
  68. }
  69. + (void)controller:(UIViewController *)viewController CameraIsAvailable:(Available)Available OrNotAvailable:(NotAvailable)NotAvailable {
  70. AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
  71. if(authStatus == AVAuthorizationStatusAuthorized) {
  72. if (Available) {
  73. Available();
  74. }
  75. }else if (authStatus == AVAuthorizationStatusNotDetermined) {
  76. if (Available) {
  77. Available();
  78. }
  79. }else{
  80. [ZYCTool alertControllerTwoButtonWithTitle:@"没有权限" message:@"点击确定前往设置打开相机权限" target:viewController notarizeButtonTitle:nil cancelButtonTitle:nil notarizeAction:^{
  81. NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
  82. if ([[UIApplication sharedApplication] canOpenURL:url]) {
  83. [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {}];
  84. }
  85. } cancelAction:^{
  86. if (NotAvailable) {
  87. NotAvailable();
  88. }
  89. }];
  90. }
  91. }
  92. + (void)controller:(UIViewController *)viewController AlbumIsAvailable:(Available)Available OrNotAvailable:(NotAvailable)NotAvailable {
  93. PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
  94. if (status == PHAuthorizationStatusRestricted || status == PHAuthorizationStatusDenied){
  95. [ZYCTool alertControllerTwoButtonWithTitle:@"没有权限" message:@"点击确定前往设置打开照片权限" target:viewController notarizeButtonTitle:nil cancelButtonTitle:nil notarizeAction:^{
  96. NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
  97. if ([[UIApplication sharedApplication] canOpenURL:url]) {
  98. [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {}];
  99. }
  100. } cancelAction:^{
  101. if (NotAvailable) {
  102. NotAvailable();
  103. }
  104. }];
  105. return;
  106. } else {
  107. if (Available) {
  108. Available();
  109. }
  110. }
  111. }
  112. + (void)countDownWithTime:(NSInteger)countTime AndCounting:(void(^)(NSInteger count))counting AndFinished:(void(^)(void))finished {
  113. __block NSInteger time = countTime; //倒计时时间
  114. dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
  115. dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
  116. dispatch_source_set_timer(timer,DISPATCH_TIME_NOW,1.0*NSEC_PER_SEC, 0); //每秒执行
  117. dispatch_source_set_event_handler(timer, ^{
  118. if(time <= 0){ //倒计时结束,关闭
  119. dispatch_source_cancel(timer);
  120. dispatch_async(dispatch_get_main_queue(), ^{
  121. if (finished) {
  122. finished();
  123. }
  124. });
  125. }else{
  126. dispatch_async(dispatch_get_main_queue(), ^{
  127. if (counting) {
  128. counting(time);
  129. }
  130. });
  131. time --;
  132. }
  133. });
  134. dispatch_resume(timer);
  135. }
  136. + (void)actionSheetWithTitleArray:(NSMutableArray *)titleArray target:(UIViewController *)viewController notarizeAction:(returnNotarizeWithIdx)returnNotarizeWithIdx {
  137. UIAlertController *alertController = [UIAlertController new];
  138. [titleArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  139. UIAlertAction *alertAction = [UIAlertAction actionWithTitle:obj style:0 handler:^(UIAlertAction *action){
  140. returnNotarizeWithIdx(idx);
  141. }];
  142. [alertController addAction:alertAction];
  143. }];
  144. UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"取消" style:1 handler:^(UIAlertAction *action){
  145. [alertController dismissViewControllerAnimated:true completion:^{}];
  146. }];
  147. [alertController addAction:alertAction];
  148. UIImpactFeedbackGenerator *generator = [[UIImpactFeedbackGenerator alloc] initWithStyle: UIImpactFeedbackStyleLight];
  149. [generator prepare];
  150. [generator impactOccurred];
  151. [viewController presentViewController: alertController animated:YES completion:nil];
  152. }
  153. + (BOOL)isHaveBang {
  154. BOOL isHaveBang = false;
  155. if (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPhone) {
  156. return isHaveBang;
  157. }
  158. if (@available(iOS 11.0, *)) {
  159. /// 利用safeAreaInsets.bottom > 0.0来判断是否是iPhone X。
  160. UIWindow *mainWindow = [[[UIApplication sharedApplication] delegate] window];
  161. if (mainWindow.safeAreaInsets.bottom > 0.0) {
  162. isHaveBang = YES;
  163. }
  164. }
  165. return isHaveBang;
  166. }
  167. /// 设置间距
  168. +(void)setLabelSpace:(UILabel*)label withSpace:(CGFloat)space withFont:(UIFont*)font {
  169. if (label.text.length == 0) {
  170. label.text = @"";
  171. return;
  172. }
  173. NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
  174. paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
  175. paraStyle.alignment = NSTextAlignmentLeft;
  176. paraStyle.lineSpacing = space; //设置行间距
  177. paraStyle.hyphenationFactor = 1.0;
  178. paraStyle.firstLineHeadIndent = 0.0;
  179. paraStyle.paragraphSpacingBefore = 0.0;
  180. paraStyle.headIndent = 0;
  181. paraStyle.tailIndent = 0;
  182. //设置字间距 NSKernAttributeName:@1.5f
  183. NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@0.0f
  184. };
  185. NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:label.text attributes:dic];
  186. label.attributedText = attributeStr;
  187. }
  188. /// 设置首行缩进和行距
  189. +(void)setLabelFirstLineHeadIndent:(UILabel*)label withSpace:(CGFloat)space withFont:(UIFont*)font setTing:(NSUInteger)headIndent {
  190. if (label.text.length == 0) {
  191. label.text = @"";
  192. return;
  193. }
  194. NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
  195. paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
  196. paraStyle.alignment = NSTextAlignmentLeft;
  197. paraStyle.lineSpacing = space; //设置行间距
  198. paraStyle.hyphenationFactor = 1.0;
  199. paraStyle.firstLineHeadIndent = font.pointSize * headIndent;
  200. paraStyle.paragraphSpacingBefore = 0.0;
  201. paraStyle.headIndent = 0;
  202. paraStyle.tailIndent = 0;
  203. //设置字间距 NSKernAttributeName:@1.5f
  204. NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@0.0f
  205. };
  206. NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:label.text attributes:dic];
  207. label.attributedText = attributeStr;
  208. }
  209. /// 设置首行缩进和行距 字距
  210. +(void)setLabel:(UILabel*)label withSpace:(CGFloat)space withFont:(UIFont*)font setLineSpace:(NSUInteger)headIndent setTextSpace:(CGFloat)textspace {
  211. if (ISEmptyString( label.text)) {
  212. return;
  213. }
  214. NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
  215. paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
  216. paraStyle.alignment = NSTextAlignmentNatural;
  217. paraStyle.lineSpacing = space; //设置行间距
  218. paraStyle.hyphenationFactor = 1.0;
  219. //paraStyle.firstLineHeadIndent = font.pointSize * headIndent;
  220. paraStyle.paragraphSpacingBefore = 0.0;
  221. paraStyle.headIndent = 0;
  222. paraStyle.tailIndent = 0;
  223. //设置字间距 NSKernAttributeName:@1.5f
  224. NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@(textspace)
  225. };
  226. NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:label.text attributes:dic];
  227. label.attributedText = attributeStr;
  228. }
  229. + (NSString *)handerResultData:(NSError *)error{
  230. NSParameterAssert(error);
  231. NSDictionary * errorInfo = error.userInfo;
  232. if ([[errorInfo allKeys] containsObject: @"com.alamofire.serialization.response.error.data"]){
  233. NSData * errorData = errorInfo[@"com.alamofire.serialization.response.error.data"];
  234. NSDictionary * errorDict = [NSJSONSerialization JSONObjectWithData: errorData options:NSJSONReadingAllowFragments error:nil];
  235. NSLog(@"App数据请求错误%@",errorDict[@"Message"]);
  236. return errorDict[@"Message"];
  237. }else{
  238. return @"服务器挂了,请联系后台";
  239. }
  240. }
  241. /**
  242. 字典判断是否为空
  243. @param dict 字典
  244. @return bool值
  245. */
  246. + (BOOL)isNullToDictionary:(NSDictionary *)dict {
  247. if (dict != nil && ![dict isKindOfClass:[NSNull class]] && dict.count != 0){
  248. return NO;
  249. }else{
  250. return YES;
  251. }
  252. }
  253. + (NSString *)getYearAndMonthAndDay{
  254. if (@available(iOS 13.0, *)) {
  255. NSDate *date = [NSDate now];
  256. NSDateFormatter *dateFormatterA = [[NSDateFormatter alloc] init];
  257. dateFormatterA.dateFormat = @"yyyy-MM-dd HH:mm:ss";
  258. return [dateFormatterA stringFromDate:date];
  259. } else {
  260. // 获取代表公历的NSCalendar对象
  261. NSCalendar *gregorian = [[NSCalendar alloc]
  262. initWithCalendarIdentifier:NSCalendarIdentifierChinese];
  263. // 获取当前日期
  264. NSDate* dt = [NSDate date];
  265. // 定义一个时间字段的旗标,指定将会获取指定年、月、日、时、分、秒的信息
  266. unsigned unitFlags = NSCalendarUnitYear |
  267. NSCalendarUnitMonth | NSCalendarUnitDay |
  268. NSCalendarUnitHour | NSCalendarUnitMinute |
  269. NSCalendarUnitSecond | NSCalendarUnitWeekday;
  270. // 获取不同时间字段的信息
  271. NSDateComponents* comp = [gregorian components: unitFlags
  272. fromDate:dt];
  273. // 获取各时间字段的数值
  274. NSLog(@"现在是%ld年" , comp.year);
  275. NSLog(@"现在是%ld月 " , comp.month);
  276. NSLog(@"现在是%ld日" , comp.day);
  277. NSLog(@"现在是%ld时" , comp.hour);
  278. NSLog(@"现在是%ld分" , comp.minute);
  279. NSLog(@"现在是%ld秒" , comp.second);
  280. NSLog(@"现在是星期%ld" , comp.weekday);
  281. // 再次创建一个NSDateComponents对象
  282. NSDateComponents* comp2 = [[NSDateComponents alloc]
  283. init];
  284. // 设置各时间字段的数值
  285. comp2.year = 2013;
  286. comp2.month = 4;
  287. comp2.day = 5;
  288. comp2.hour = 18;
  289. comp2.minute = 34;
  290. // 通过NSDateComponents所包含的时间字段的数值来恢复NSDate对象
  291. NSDate *date = [gregorian dateFromComponents:comp2];
  292. NSLog(@"获取的日期为:%@" , date);
  293. NSDateFormatter *dateFormatterA = [[NSDateFormatter alloc] init];
  294. dateFormatterA.dateFormat = @"yyyy年MM月dd日";
  295. return [dateFormatterA stringFromDate:dt];
  296. }
  297. }
  298. + (NSString *)monthAndDayAndHoursAndMinutes:(NSString *)dateString{
  299. //dateString FORMAT yyyy-MM-dd HH:mm:ss
  300. NSDateFormatter *dateFormatterA = [[NSDateFormatter alloc] init];
  301. dateFormatterA.dateFormat = @"yyyy-MM-dd HH:mm:ss";
  302. NSDate *date = [dateFormatterA dateFromString:dateString];
  303. NSDateFormatter *dateFormatterB = [[NSDateFormatter alloc] init];
  304. dateFormatterB.dateFormat = @"MM-dd HH:mm";
  305. return [dateFormatterB stringFromDate:date];
  306. }
  307. + (NSString *)yearMonthAndDay:(NSString *)dateString{
  308. //dateString FORMAT yyyy-MM-dd HH:mm:ss
  309. NSDateFormatter *dateFormatterA = [[NSDateFormatter alloc] init];
  310. dateFormatterA.dateFormat = @"yyyy-MM-dd HH:mm:ss";
  311. NSDate *date = [dateFormatterA dateFromString:dateString];
  312. NSDateFormatter *dateFormatterB = [[NSDateFormatter alloc] init];
  313. dateFormatterB.dateFormat = @"yyyy-MM-dd";
  314. return [dateFormatterB stringFromDate:date];
  315. }
  316. + (NSString *)yearMonthAndDayHourMinuesSecond:(NSString *)dateString{
  317. //dateString FORMAT yyyy-MM-dd HH:mm:ss
  318. NSDateFormatter *dateFormatterA = [[NSDateFormatter alloc] init];
  319. dateFormatterA.dateFormat = @"yyyy-MM-dd HH:mm:ss";
  320. NSDate *date = [dateFormatterA dateFromString:dateString];
  321. NSDateFormatter *dateFormatterB = [[NSDateFormatter alloc] init];
  322. dateFormatterB.dateFormat = @"yyyy/MM/dd HH:mm";
  323. return [dateFormatterB stringFromDate:date];
  324. }
  325. + (NSString *)MonthAndDay:(NSString *)dateString
  326. {
  327. NSDateFormatter *dateFormatterA = [[NSDateFormatter alloc] init];
  328. dateFormatterA.dateFormat = @"yyyy-MM-dd";
  329. NSString * subData = [dateString substringToIndex:10];
  330. NSDate *date = [dateFormatterA dateFromString:subData];
  331. NSDateFormatter *dateFormatterB = [[NSDateFormatter alloc] init];
  332. dateFormatterB.dateFormat = @"MM月dd日";
  333. return [dateFormatterB stringFromDate:date];
  334. }
  335. + (NSDate *)StringReturnDate:(NSString *)dateString
  336. {
  337. NSDateFormatter *dateFormatterA = [[NSDateFormatter alloc] init];
  338. dateFormatterA.dateFormat = @"yyyy-MM-dd HH:mm:ss";
  339. NSDate *date = [dateFormatterA dateFromString:dateString];
  340. return date;
  341. }
  342. + (NSString *)getCommenttext:(NSInteger)number{
  343. if (number == 0) {
  344. return @"0";
  345. }else if (100 <= number && number <= 999){
  346. return [NSString stringWithFormat:@"%.1f百",number/100.0f];
  347. }else if (1000 <= number && number <= 9999){
  348. return [NSString stringWithFormat:@"%.1f千",number/1000.0f];
  349. }else if (10000 <= number){
  350. return [NSString stringWithFormat:@"%.1f万",number/10000.0f];
  351. }else{
  352. return [NSString stringWithFormat:@"%ld",(long)number];
  353. }
  354. return @"0";
  355. }
  356. + (NSMutableArray *)setToArray:(NSMutableSet *)set{
  357. NSEnumerator * en = [set objectEnumerator];
  358. id depart;
  359. NSMutableArray *arr = [NSMutableArray array];
  360. while (depart = [en nextObject]) {
  361. [arr addObject:depart];
  362. }
  363. return arr;
  364. }
  365. + (NSMutableAttributedString *)checkOfString:(NSString *)infoStr KeyString:(NSString *)keyString
  366. {
  367. if (keyString.length == 0) {
  368. return [[NSMutableAttributedString alloc] initWithString:@""];
  369. }
  370. NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:infoStr];
  371. [attrString addAttribute:(NSString *)NSForegroundColorAttributeName
  372. value:UIColorHex(0099FF)
  373. range:[infoStr rangeOfString:keyString]];
  374. return attrString;
  375. }
  376. + (NSMutableAttributedString *)checkOfString:(NSString *)infoStr withSearchText:(NSString *)text
  377. {
  378. if (infoStr.length == 0) {
  379. return [[NSMutableAttributedString alloc] initWithString:@""];
  380. }
  381. if (text.length == 0) {
  382. return [[NSMutableAttributedString alloc] initWithString:infoStr];
  383. }
  384. NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:infoStr];
  385. [attrString addAttribute:(NSString *)NSForegroundColorAttributeName
  386. value:UIColorHex(EA3729)
  387. range:[infoStr rangeOfString:text]];
  388. return attrString;
  389. }
  390. + (NSMutableAttributedString *)checkOfString:(NSString *)infoStr withSearchText:(NSString *)text withColor:(UIColor *)color
  391. {
  392. if (infoStr.length == 0) {
  393. return nil;
  394. }
  395. if (text.length == 0) {
  396. return [[NSMutableAttributedString alloc] initWithString:infoStr];
  397. }
  398. NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:infoStr];
  399. [attrString addAttribute:(NSString *)NSForegroundColorAttributeName
  400. value:color
  401. range:[infoStr rangeOfString:text]];
  402. return attrString;
  403. }
  404. + (NSMutableAttributedString *)checkOfString:(NSString *)infoStr withSearchText:(NSString *)text bgtextColor:(UIColor *)bgColor foreTextColor:(UIColor *)foreColor font:(UIFont *)font
  405. {
  406. if (infoStr.length == 0) {
  407. return [[NSMutableAttributedString alloc] initWithString:@""];
  408. }
  409. if (text.length == 0) {
  410. return [[NSMutableAttributedString alloc] initWithString:infoStr];
  411. }
  412. NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:infoStr];
  413. [attrString addAttribute:(NSString *)NSForegroundColorAttributeName
  414. value:bgColor
  415. range:NSMakeRange(0, infoStr.length)];
  416. [attrString addAttribute:(NSString *)NSFontAttributeName
  417. value:font
  418. range:NSMakeRange(0, infoStr.length)];
  419. [attrString addAttribute:(NSString *)NSForegroundColorAttributeName
  420. value:foreColor
  421. range:[infoStr rangeOfString:text]];
  422. return attrString;
  423. }
  424. + (NSString *)getFileNameImage:(NSString *)fileName
  425. {
  426. NSString * name = [[fileName pathExtension] lowercaseString];
  427. if ([name hasSuffix:@"doc"] || [name hasSuffix:@"docx"]) {
  428. return @"icon_word";
  429. }else if([name hasSuffix:@"xls"] || [name hasSuffix:@"xlsx"]){
  430. return @"icon_excel";
  431. }else if([name hasSuffix:@"ppt"] || [name hasSuffix:@"pptx"] || [name hasSuffix:@"pptm"]){
  432. return @"icon_ppt";
  433. }else if([name hasSuffix:@"pdf"]){
  434. return @"icon_pdf";
  435. }else if([name hasSuffix:@"zip"]){
  436. return @"icon_yasuowenjian";
  437. }else if([name hasSuffix:@"psd"]){
  438. return @"icon_psd";
  439. }else if([name hasSuffix:@"ai"]){
  440. return @"icon_ai";
  441. }else if([name hasSuffix:@"txt"]){
  442. return @"icon_txt";
  443. }else if([name hasSuffix:@"html"]){
  444. return @"icon_html";
  445. }else if([name hasSuffix:@"png"] || [name hasSuffix:@"jpg"] || [name hasSuffix:@"jpeg"] || [name hasSuffix:@"bmp"]){
  446. return nil;
  447. }else{
  448. return @"icon_weizhiwenjian";
  449. }
  450. }
  451. @end