Reputation: 85
I'm coding to display a php echo
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init];
[request setTimeoutInterval:180.0];
[request setURL:[NSURL URLWithString:@"http://localhost:8888/MAMP/signup/getkey.php"]];
[request setHTTPMethod:@"POST"];
NSString *key = [[NSString alloc] initWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil] encoding:NSUTF8StringEncoding];
When I compile, I have this warning message : Unused variable key
Where is the problem?
Upvotes: 0
Views: 5920
Reputation: 38634
If you don't need to use the key, simply comment it out by //
// NSString *key = [[NSString alloc] initWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil] encoding:NSUTF8StringEncoding];
Upvotes: 0
Reputation: 2987
It is because you don't do anything with key
. You simply alloc and init it, but never really use it.
You could do something like NSLog(@"%@",key);
and the error will go away.
The other option is to set Unused Variables
to warnings. Go to your project target, Build settings, then find the below image and change Unused Variables
to Yes
. This will change it from and error to a warning.
Upvotes: 5
Reputation: 8200
On the last line you are assigning key to a value but you never use it. You can configure it to not throw an error, but rather a warning if you do not use a variable. Otherwise just comment out the assignment of key.
Upvotes: 0