簡體   English   中英

如何修復 xcode 警告“未使用表達式結果”

[英]how to fix xcode warning “Expression result unused”

我正在使用我的應用程序進行注冊過程,用戶輸入一個我檢查我的數據庫的數字。總之長話短說,我將代碼傳遞到我的NSString *startURL有一個我無法擺脫的警告,它說

“未使用的表達式結果”

你有沒有經歷過這樣的事情,如果有,我該如何解決?

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

    }

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

這是因為括號。 通過編寫 (blabla),它變成了一個表達式,您沒有將其用作表達式,因此編譯器會抱怨。

更改為[NSString stringWithFormat: ...]; 它變成了一種方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM