因未捕获的异常终止应用程序' NSInvalidArgumentException'五

时间:2014-06-10 14:08:02

标签: objective-c

运行我的应用时遇到此错误: 我的代码是:

- (IBAction)yes:(id)sender {
    UIAlertView *msgbox=[[UIAlertView alloc]initWithTitle:@"Warrning" message:nil delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
    if ([_usernametextbox.text length]>0)
    {
        if ([_passwordtextfield.text length]>0)
        {
            NSMutableString *ms=[[NSMutableString alloc]initWithFormat:url,_usernametextbox.text,_passwordtextfield];
            NSURL *serviceurl=[[NSURL alloc] initWithString:ms];
            NSError *error=nil;
            NSData *data=[NSData dataWithContentsOfURL:serviceurl options:NSDataReadingUncached error:&error];
            NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
            NSString *jsondata=[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
            SBJSON *parsedata=[[SBJSON alloc] init];
            dic=[parsedata objectWithString:jsondata error:nil];
            if([dic count]>0)
            {
                NSMutableString *st=[[NSMutableString alloc]initWithString:[dic objectForKey:@"loginResult:@""+"]]; //@" " withString:@"+"
                if ([st isEqualToString:@"YES"])
                {
                    UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"accept" message:@"correct username" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                    [alert show];


                }
                else
                {
                    UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"Error" message:@"Invalid UserName and Password" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                    [alert show];

                }
            }
        }
        else
        {
            msgbox.message=@"Please Enter Password...";
            [msgbox show];
        }
    }
    else
    {
        msgbox.message=@"Please Enter Username...";
        [msgbox show];


}

我收到错误:

  

由于未捕获的异常而终止应用   ' NSInvalidArgumentException',原因:' * - [NSConcreteData   initWithContentsOfURL:options:error:]:nil URL参数'

就行:

NSMutableString *st=[[NSMutableString alloc]initWithString:[dic objectForKey:@"loginResult:@""+"]]; //@" " withString:@"+" if ([st isEqualToString:@"YES"])

0 个答案:

没有答案
相关问题