我从数据库中检索名称并将他们的名字和姓氏存储在 NSMutableDictionary 中,并将它们存储在 NSMutableArray 中。在数据库中,我的名称具有特殊字符,例如“ñ”、“Ç”等,当我将名称存储在变量中时,它会存储 ,这会使我的程序崩溃。
我不想限制用户输入,所以我必须保留这些字符。但是有没有办法在不输出的情况下用这些字符检索这些名称?
ConDAO *con = [[ConDAO alloc] init];
NSMutableArray *resultSet = [con executeMySqlCommand:[NSString stringWithFormat:(Long query here)]];
NSMutableDictionary * endList = [[NSMutableDictionary alloc] init];
[endList setObject: @"" forKey:@"surname"];
[endList setObject: @"" forKey:@"name"];
resultSet =(NSMutableArray *)[resultSet arrayByAddingObject:endList];
for (int i =0; i< [resultSet count]-1; ++i)
{
NSMutableDictionary *temp = (NSMutableDictionary *) [resultSet objectAtIndex:i];
...
}
-(NSMutableArray *) executeMySqlCommand: (NSString *) mysqlCommand{
LoginData* loginData=[self dataObject];
NSString *post =[NSString stringWithFormat:@"username=%@&password=%@&mysqlCommand=%@",
loginData.loginName, loginData.loginPassword, mysqlCommand ];
NSString *hostStr = @myIP;
hostStr = [hostStr stringByAppendingString:post];
NSString *encodeURL =[hostStr stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding];
NSData *dataURL = [NSData dataWithContentsOfURL: [ NSURL URLWithString: encodeURL ]];
NSString *serverOutput = [[NSString alloc] initWithData:dataURL encoding: NSASCIIStringEncoding];
if ([serverOutput length]<=0) return nil;
NSError * error;
NSMutableArray *data = [NSJSONSerialization JSONObjectWithData:dataURL options:0 error:&error];
return data;
}