我正在开发 iOS 应用程序。在一种情况下,我正在像这样向服务器发送电话号码和一些短信
- (void)postData:(NSString *)message :(NSString *)mobileno
{
NSLog(@"postData is called");
@try
{
NSString *urlString = [NSString stringWithFormat:@"http://anlgelist.commonshell.net/api/account"];
NSURL *url = [[NSURL alloc] initWithString:urlString];
NSMutableURLRequest *urlRequest1=[NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSMutableDictionary *postDictionary=[[NSMutableDictionary alloc]init];
[postDictionary setValue:message forKey:@"Message"];
[postDictionary setValue:mobileno forKey:@"MobileNumber"];
SBJsonWriter *jsonWriter = [SBJsonWriter new];
NSError *error = nil;
NSLog(@"~~~~~~~~ postDictionary is %@",postDictionary);
NSString * jsonDataString =[jsonWriter stringWithObject:postDictionary];
if ( ! jsonDataString )
{
NSLog(@"Error: %@", error);
}
NSData *requestData = [NSData dataWithBytes:[jsonDataString UTF8String] length:[jsonDataString length]];
[urlRequest1 setHTTPMethod:@"PUT"];
[urlRequest1 setValue:@"application/json" forHTTPHeaderField:@"content-type"];
[urlRequest1 setHTTPBody: requestData];
connection1 = [NSURLConnection connectionWithRequest:urlRequest1 delegate:self];
}
@catch (NSException *exception)
{
////NSLog(@"exception is %@",exception);
@throw exception;
}
}
我不断调用此 Web 服务来发送详细信息。但有时我收到以下错误并且应用程序崩溃。
<Error>: -[__NSCFDictionary _expandedCFCharacterSet]: unrecognized selector sent to instance 0x14fdf350
我以前没有遇到过这种错误。我用谷歌搜索但没有找到解决方案。
崩溃报告现为