我转换希伯来字符串并尝试将其添加到数组中,这是代码:
NSMutableArray * myarray;
// @property(strong,nonatomic) NSMutableArray *stringArray;
for (NSString * item in stringArray) {
NSData * UTF8 = [item dataUsingEncoding:NSUTF8StringEncoding];
NSString * myString = [[NSString alloc] initWithData:UTF8 encoding:NSUTF8StringEncoding];
NSLog(@"myString = %@",myString); // Hebrew str log fine
[myarray addObject:myString];
}
NSString * ConvetData = [NSString stringWithFormat:@"%@",myarray];
NSLog(@"ConvetData = %@",ConvetData); // null
newitem.ingredient = ConvetData;
数组输出为null,如何从转换数据中创建一个字符串?
答案 0 :(得分:0)
您需要初始化myarray
:NSMutableArray *myarray =[[NSMutableArray alloc] init];