これはうまくいくと思います。この回答から取得した reversedString のロジック
#import "NSString+CustomCrypto.h"
@implementation NSString (CustomCrypto)
- (NSString *)reversedString{
NSMutableString *reversedString = [NSMutableString stringWithCapacity:[self length]];
[self enumerateSubstringsInRange:NSMakeRange(0,[self length])
options:(NSStringEnumerationReverse | NSStringEnumerationByComposedCharacterSequences)
usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
[reversedString appendString:substring];
}];
return [NSString stringWithString:reversedString];
}
- (NSString *)splicedString{
NSInteger index = [self length]/2;
NSString *subString = [self substringFromIndex:index];
NSString *secondString = [self substringToIndex:index];
return [subString stringByAppendingString:secondString];
}
- (NSString *)customCryptoString{
NSString *splicedString = [self splicedString];
NSString *reversedString = [self reversedString];
return [NSString stringWithFormat:@"%@ %@ %@",self, splicedString, reversedString];
}
文字列のカテゴリ メソッドを呼び出す
NSLog(@"%@",[@"abcdefgh" customCryptoString]);
出力: abcdefgh efghabcd hgfedcba