MessageUI.mm 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // MessageUI.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/11/9.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "MessageUI.h"
  9. #import "Header.h"
  10. @implementation MessageUI
  11. //显示传递的错误信息
  12. +(void)ShowError:(NSString *) str{
  13. [MessageUI ShowError:str title:TS("Error_Warning")];
  14. }
  15. //显示传递的错误信息和标题
  16. +(void)ShowError:(NSString *) str title:(NSString *)title{
  17. [SVProgressHUD showErrorWithStatus:str duration:3];
  18. }
  19. //格局传递的错误值int显示错误信息
  20. +(void)ShowErrorInt:(int) errorno{
  21. [MessageUI ShowError:[MessageUI GetErrorStr:errorno]];
  22. }
  23. //根据传入的错误值和标题显示错误信息
  24. +(void)ShowErrorInt:(int) errorno title:(NSString *)title{
  25. [MessageUI ShowError:[MessageUI GetErrorStr:errorno] title:title];
  26. }
  27. //根据int值获取错误信息(例:-11301就是密码错误)
  28. +(NSString *)GetErrorStr:(int)intError{
  29. NSString *intErr = [NSString stringWithFormat:@"%d", intError];
  30. //用plist文件取枚举值
  31. NSString *errorPath = [[NSBundle mainBundle] pathForResource:@"error.plist" ofType:nil];
  32. NSDictionary *data = [[NSMutableDictionary alloc] initWithContentsOfFile:errorPath];
  33. NSString *errorString = [data valueForKey:intErr];
  34. if ( !errorString ) {
  35. return [NSString stringWithFormat:@"%@[%d]", TS("Unknown_Error"), intError];
  36. }
  37. if ([TS([errorString UTF8String]) hasPrefix:@"EE_"]) {
  38. return [NSString stringWithFormat:@"%@[%@,%d]", TS("Unknown_Error"), errorString, intError];
  39. }
  40. return [NSString stringWithFormat:@"%@[%d]", TS([errorString UTF8String]), intError];
  41. }
  42. @end