A syntax error in expression, near `variable)'.

Discussion in 'iOS Programming' started by AbhishekApple, Sep 9, 2010.

  1. AbhishekApple macrumors member

    Joined:
    Aug 5, 2010
    #1
    NSString variable is not accepting value ( ==> Arrow specifies breakpoint)

    Code:
    -(IBAction)btnLoginGoClicked:(id)sender
    {
    		NSString *userid =txtUserId.text;  //==>on breakpoint while debugging  value shown by userid is "abcd"
    		NSString *pass = txtPassword.text; //==>on breakpoint  while debugging  value shown by pass is "yyy"	
    		
    		NSString *loginurl= [[NSString alloc] initWithFormat:@"http://abc.com/email=%@&password=%@" ,userid,pass];  
    		
    		//==>on breakpoint while debugging  value shown by loginurl is  NSString* loginurl <variable nil
    	
    		NSURL *url = [NSURL URLWithString:loginurl];
    		ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    		[loginurl release];
    		[request setDelegate:self];
    		[request startAsynchronous];
    }
    
    if i keep only starting 2 lines then the value of text field are not accepted at all but their is no error and execution continues..
    but when i print breakpoint in gdb it shows following error description
    Printing description of loginurl:
    A syntax error in expression, near `variable)'.
    A syntax error in expression, near `variable)'.

    Also, if i replace the following same error exists
    Code:
    //Replace ==>
    
    NSString *loginurl= [[NSString alloc] initWithFormat:@"http://abc.com/email=%@&password=%@" ,userid,pass];  
    		
    //with ==>
    
    NSString *loginurl=@"test";
    
     
  2. Luke Redpath macrumors 6502a

    Joined:
    Nov 9, 2007
    Location:
    Colchester, UK
    #2
    The line that is failing in your posted code makes no sense syntactically.
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    Is that your actual method, with all that extra "==>" commentary?
     
  4. mpramodjain macrumors regular

    Joined:
    Nov 20, 2008
    Location:
    Banglore
    #4
    Hi , Did you got any work around for this.

    Please share the resolution
     
  5. AbhishekApple thread starter macrumors member

    Joined:
    Aug 5, 2010
    #5
    Try to print variables value using nslog if it gives required output thn thr shldn't b any problem working with same code....

    else check with value assigning of strings (memory allocation)..
     

Share This Page