Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/*
2
 * Copyright 2019 Google
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
 
17
#import <TargetConditionals.h>
18
#if TARGET_OS_IOS || TARGET_OS_TV
19
 
20
#import "FirebaseInAppMessaging/Sources/Private/Util/NSString+FIRInterlaceStrings.h"
21
 
22
@implementation NSString (InterlaceStrings)
23
 
24
+ (NSString *)fir_interlaceString:(NSString *)stringOne withString:(NSString *)stringTwo {
25
  NSMutableString *interlacedString = [NSMutableString string];
26
 
27
  NSUInteger count = MAX(stringOne.length, stringTwo.length);
28
 
29
  for (NSUInteger i = 0; i < count; i++) {
30
    if (i < stringOne.length) {
31
      NSString *firstComponentChar =
32
          [NSString stringWithFormat:@"%c", [stringOne characterAtIndex:i]];
33
      [interlacedString appendString:firstComponentChar];
34
    }
35
    if (i < stringTwo.length) {
36
      NSString *secondComponentChar =
37
          [NSString stringWithFormat:@"%c", [stringTwo characterAtIndex:i]];
38
      [interlacedString appendString:secondComponentChar];
39
    }
40
  }
41
 
42
  return interlacedString;
43
}
44
 
45
@end
46
 
47
#endif  // TARGET_OS_IOS || TARGET_OS_TV