Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
aoa i am making an f..
app of finance system. i had maked web method login name in c# json wcf.
but whenever i call this methos in ios it is getting a thread...
my code for login form is:
C#
(IBAction)yes:(id)sender

<pre lang="cs">UIAlertView *msgbox=[[UIAlertView alloc]initWithTitle:@&quot;Warrning&quot; message:nil delegate:self cancelButtonTitle:@&quot;Ok&quot; otherButtonTitles:nil, nil];
    if ([usernametextbox.text length]&gt;0)
    {
        if ([passwordtextbox.text length]&gt;0)
        {
            NSMutableString *ms=[[NSMutableString alloc]initWithFormat:@&quot;http://192.168.1.2:8082/ipad/ipadservice.svc/login?UserName=%@&amp;Pasword=%@&quot;,usernametextbox.text,passwordtextbox.text];
            NSURL *serviceurl=[[NSURL alloc] initWithString:ms];
            NSError *error=nil;
            NSData *data=[NSData dataWithContentsOfURL:serviceurl options:NSDataReadingUncached error:&amp;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]&gt;0)
            {
                NSMutableString *st=[[NSMutableString alloc]initWithString:[dic objectForKey:@&quot;loginResult&quot;]];
                if ([st isEqualToString:@&quot;YES&quot;])
                {
                    UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@&quot;accept&quot; message:@&quot;correct username&quot; delegate:nil cancelButtonTitle:@&quot;OK&quot; otherButtonTitles:nil, nil];
                    [alert show];


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

                }
            }
        }
        else
        {
            msgbox.message=@&quot;Please Enter Password...&quot;;
            [msgbox show];
        }
    }
    else
    {
        msgbox.message=@&quot;Please Enter Username...&quot;;
        [msgbox show];
    }
}</pre>


i am getting error on

if ([st isEqualToString:@&amp;quot;YES&amp;quot;])
{

and application will terminate on this line and the thread is

C#
#import <UIKit/UIKit.h>

#import "AppDelegate.h"

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

signal sigabrt..
how can i overcome this iisue?
Posted

it is the "normal" behavior if one of both isnt a valid string. check the code path of creating st in a more detailed fashion.
C#
SBJSON *parsedata=[[SBJSON alloc] init];
dic=[parsedata objectWithString:jsondata error:nil]; //error check!!!
if([dic count]&gt;0)//too simple check
{
NSMutableString *st=[[NSMutableString alloc]initWithString:[dic objectForKey:@&quot;loginResult&quot;]];//here comes the problem
                
if ([st isEqualToString:@&quot;YES&quot;])
 
Share this answer
 
Comments
Member 10690757 10-Jun-14 12:17pm    
how can i remove this error?
KarstenK 11-Jun-14 11:44am    
have you updated yor code? and where is the error now?
Member 10690757 11-Jun-14 11:49am    
error is on
{
NSMutableString *st=[[NSMutableString alloc]initWithString:[dic objectForKey:@"loginResult"]];//here comes the problem

if ([st isEqualToString:@"YES"])
in this line

Member 10690757 10-Jun-14 12:18pm    
kindly do tell
Member 10907890 5-Aug-14 4:07am    
can you give nslog error like reason:
check the dic result like that

NSString *s = [dic objectForKey:@"loginResult"];

if( s == nil )
{
 NSLog(@"ERROR: No loginResult provided");
}


consider writing clean and stable code :-O
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900