NSString is not initialized when declared locally???

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

  1. AbhishekApple macrumors member

    Aug 5, 2010
    I am trying to initialize a NSstring,NSUrl but it is not accepting value with in a touchup event if variables are declared locally but if i declare NSstring globally it accepts value:confused:

    NSString *userid,*pass;
    pass= txtPassword.text;
    NSString *loginurl= [[NSString alloc] initWithFormat:@"http://abc.com/email=%@&password=%@&chk=&requestFlag=appRequest",userid,pass];  
    NSUrl *url = [NSURL URLWithString:loginurl];
    ===>shows NSString * loginurl <variable nil    ===>on breakpoint 
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [loginurl release];
    [request setDelegate:self];
    [request startAsynchronous];
    Pls ny one can explain
  2. Sykte macrumors regular

    Aug 26, 2010
    Hint 1:
    A couple of the variables that should be pointers are not.

    Hint 2:
    If a variable or object are returning nil when they should be initialized, check the object/variable immediately after initialization.
  3. ulbador macrumors 68000


    Feb 11, 2010
    The previous poster is correct. loginurl and url should be declared as pointers (*)
  4. robbieduncan Moderator emeritus


    Jul 24, 2002
    And the class NSUrl does not exist (but NSURL does).

    I suspect that instead of copy/pasting the exact code which is the only way to get useful help the poster has typed roughly the same, but not exactly the same into here.

    OP: if you want help:

    1) Copy and paste the exact code
    2) Do a clean build and not any compiler warnings. If there are any then fix them and go back to 1)

Share This Page