Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ZXEmailAddressParsedResult.m 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright 2012 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "ZXEmailAddressParsedResult.h"
  17. #import "ZXParsedResultType.h"
  18. @implementation ZXEmailAddressParsedResult
  19. - (id)initWithTo:(NSString *)to {
  20. return [self initWithTos:@[to] ccs:nil bccs:nil subject:nil body:nil];
  21. }
  22. - (id)initWithTos:(NSArray *)tos
  23. ccs:(NSArray *)ccs
  24. bccs:(NSArray *)bccs
  25. subject:(NSString *)subject
  26. body:(NSString *)body {
  27. if (self = [super initWithType:kParsedResultTypeEmailAddress]) {
  28. _tos = tos;
  29. _ccs = ccs;
  30. _bccs = bccs;
  31. _subject = subject;
  32. _body = body;
  33. }
  34. return self;
  35. }
  36. - (NSString *)emailAddress {
  37. return !self.tos || self.tos.count == 0 ? nil : self.tos[0];
  38. }
  39. - (NSString *)mailtoURI {
  40. return @"mailto:";
  41. }
  42. - (NSString *)displayResult {
  43. NSMutableString *result = [NSMutableString stringWithCapacity:30];
  44. [ZXParsedResult maybeAppendArray:self.tos result:result];
  45. [ZXParsedResult maybeAppendArray:self.ccs result:result];
  46. [ZXParsedResult maybeAppendArray:self.bccs result:result];
  47. [ZXParsedResult maybeAppend:self.subject result:result];
  48. [ZXParsedResult maybeAppend:self.body result:result];
  49. return result;
  50. }
  51. @end