小编Ock*_*kie的帖子

连接混合从右到左和从左到右语言字符串时的奇怪行为

输入:

\n

tempTextArray:\n\xe2\x96\xbf 3 个元素

\n
- 0 : "\xd7\x96\xd7\x94 \xd7\x9e\xd7\x91\xd7\x97\xd7\x9f"\n- 1 : "7 x 5 abc"\n- 2 : "other text"\n
Run Code Online (Sandbox Code Playgroud)\n

当做一个简单的tempText = tempTextArray.joined(" | ")结果时,结果并没有将所有元素放置在我期望的位置...结果:

\n
Printing description of tempText:\n"\xd7\x96\xd7\x96\xd7\x94 \xd7\x9e\xd7\x91\xd7\x97\xd7\x9f | 7 x 5 abc | other text"\n
Run Code Online (Sandbox Code Playgroud)\n

这是我第一次将从右到左与从左到右的文本结合起来,以前有人处理过类似的情况吗?

\n

我的应用程序正在从后端接收翻译,因此我不知道哪些元素被翻译成(在本例中)希伯来语,以及我将以默认语言(英语)收到哪些元素

\n

arrays right-to-left ios left-to-right swift

5
推荐指数
1
解决办法
487
查看次数

stringByAppendingString导致系统内存耗尽应用程序

当我在"大"(37000行)文本文件上运行以下代码时,是否有人能指出我系统告诉我内存应用程序耗尽的方向?

-(void) writeToFile: (NSString*)filePath withSeparator:(NSString*) fieldSep{
NSString* completeFile = [[[NSString alloc] initWithString:@""] autorelease];
for(int i=0;i<[self numberOfRows];i++){
    printf("im at line number... %i of %i\n",i,[self numberOfRows]);
    for(int j=0;j<[self numberOfColumns];j++){
        completeFile = [completeFile stringByAppendingString:[self objectInRow:i column:j]];

        if(j<[self numberOfColumns]-1){
            //separator for all columns except last one
            completeFile = [completeFile stringByAppendingString:fieldSep];
        }
    }
        completeFile = [completeFile stringByAppendingString:@"\n"];
}
NSError *error = nil;
[completeFile writeToFile:filePath atomically:NO
                 encoding:NSStringEncodingConversionAllowLossy error:&error];
if(error){
    NSLog(@"Error writing file at %@\n%@",
          filePath, [error localizedFailureReason]);
}
Run Code Online (Sandbox Code Playgroud)

}

我出于调试原因添加了printf,前面似乎有4000行,然后它慢慢减速...我的文件包含超过37000行,类似于这些:

1893-11-6   136 194 165
Run Code Online (Sandbox Code Playgroud)

objective-c

3
推荐指数
1
解决办法
213
查看次数

标签 统计

arrays ×1

ios ×1

left-to-right ×1

objective-c ×1

right-to-left ×1

swift ×1