2011-07-14 53 views
4

我做我的应用程序的注册过程,其中用户在一个数字,我核对我的分贝进入..反正长话短说,我通过代码到我的NSString * startURL有一个警告,我无法摆脱的,它说如何解决Xcode的警告“表达式结果未使用”

“表达式结果未使用”

你有没有经历过这样的事,如果让我怎么解决?

-(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]; 

    } 
+0

这不是你的问题的答案,但你为什么要分配一个新的字符串('code'),然后为它指定tempRegCode的值?你可以毫无问题地使用tempRegCode。 – sosborn

+0

我只是这样做,认为它可以解决这个问题,因为我不知道为什么会发生问题,我认为这可能是奇怪的,因为我改变了我的代码,而没有将传入的字符串传递给另一个字符串。 –

+0

公平 - 我们都有过这些时刻:) – sosborn

回答

12

您不能只是做(@"http://188.162.17.44:8777/ICService/?RegCode=%@",code)。使用[NSString stringWithFormat:@"http://188.162.17.44:8777/ICService/?RegCode=%@", tempRegCode]

+0

谢谢,我知道这是...有一个赫克有我的头去了几天!大声笑感谢指出明显! –

2

这是因为括号。通过编写(blabla)它变成了一个表达式,你并没有将它用作表达式,因此编译器会抱怨。

更改为[NSString stringWithFormat: ...];,它成为一种方法。

相关问题