Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to fix xcode warning "Expression result unused"

I am doing a registration process with my app where the user enters in a number that I check against my db.. anyway long story short where I pass code into my NSString *startURL have a warning I cannot get rid of, it says

"Expression result unused"

have you ever experienced anything like this and if so how do I fix it?

   -(void)startRegConnect:(NSString *)tempRegCode{

        //tempRegCode = S.checkString;
        NSLog(@"tempRegCode from RegConnection =%@",tempRegCode);


        NSString *code = [[NSString alloc] initWithString:tempRegCode];
        //urlstart string
        NSString *startURL = (@"http://188.162.17.44:8777/ICService/?RegCode=%@",code); //warning here

        NSURL *url = [NSURL URLWithString:startURL];

        //create a request object with that url
        NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30];

        //clear out the exisiting connection if there is on
        if (connectionInProgress) {
            [connectionInProgress cancel];
            [connectionInProgress release];
        }

        //Instantiate the object to hold all incoming data
        [cookieData release];
        cookieData = [[NSMutableData alloc]init];

        //create and initiate the connection - non-blocking
        connectionInProgress = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];

    }
like image 812
C.Johns Avatar asked Jul 14 '11 05:07

C.Johns


2 Answers

You can't just do (@"http://188.162.17.44:8777/ICService/?RegCode=%@",code). Use [NSString stringWithFormat:@"http://188.162.17.44:8777/ICService/?RegCode=%@", tempRegCode].

like image 153
jtbandes Avatar answered Sep 30 '22 20:09

jtbandes


It's because of the parenthesis. By writing (blabla) it becomes an expression, which you are not using as an expressing, hence the compiler complains.

Change to [NSString stringWithFormat: ...]; and it becomes a method.

like image 21
CocoaChris Avatar answered Sep 30 '22 18:09

CocoaChris