how to fix xcode warning "Expression result unused"
19,206
Solution 1
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]
.
Solution 2
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.
Related videos on Youtube
Author by
C.Johns
Updated on July 09, 2022Comments
-
C.Johns almost 2 years
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]; }
-
C.Johns almost 13 yearsthanks, I know this... was having one of those where the heck has my head gone days! lol thanks for pointing out the obvious!