2013-02-25 50 views
0

我想在一個陣列中打開一個URL,但它不工作打開URL。這是我的代碼:與陣列的iOS SDK

NSArray *platformarray = [[NSArray alloc] initWithObjects:iphonestring,ipadstring,androidstring,blackberrystring, windowsstring,nil]; 


    NSString *url = [NSString stringWithFormat:@"http://xxx.nl/appofferte.php?hoedanigheid=%@&bedrijfsnaam=%@&naam=%@&email=%@&telefoon=%@&platformen=%@", hoedanigheid, bedrijf.text, naam.text, email.text, telefoon.text, platformarray]; 
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]]; 

    NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; 

誰能幫我把數組放在1個變量中?

+0

做它沒有更多鈔票給你像這樣做,,的NSString * URL = [的NSString stringWithFormat:@「http://xxx.nl/appofferte.php?hoedanigheid=%@&bedrijfsnaam=%@&naam=%@&email=%@&telefoon=%@&platformen= %@%@%@%@%@「,hoedanigheid,b edrijf.text,naam.text,email.text,telefoon.text,iphonestring,ipadstring,androidstring,blackberrystring,windowsstring]; – Dilip 2013-02-25 13:47:22

+0

是該陣列,其中可變 – NAZIK 2013-02-25 13:47:36

+0

@Dilip否,PHP-文件發送電子郵件,所以它是1個可變更爲具體。是否有可能在1個變量中發送「platformarray」? – 2013-02-25 13:49:26

回答

0

如果陣列中的所有項目都是字符串,那麼你可以將它們結合起來:

NSString* combined = [platformarray componentsJoinedByString:@","]; 
+0

他仍然繼續加載網址,但無法完成。沒有發送E-mail – 2013-02-25 14:08:06

+0

你得到你的'錯誤 - 連接:(NSURLConnection的*)連接didFailWithError:(NSError *)error'委託功能? – jjv360 2013-02-25 14:08:48

+0

對不起,它的工作原理! – 2013-02-25 14:36:31

0
hoedanigheid=%@&bedrijfsnaam=%@&naam=%@&email=%@&telefoon=%@&platformen=%@", hoedanigheid, bedrijf.text, naam.text, email.text, telefoon.text, platformarray]; 

變化platformarray到[platformarray objectAtIndex:thePlatformThatIWant];例如:[platformarray objectAtIndex:0];

hoedanigheid=%@&bedrijfsnaam=%@&naam=%@&email=%@&telefoon=%@&platformen=%@", hoedanigheid, bedrijf.text, naam.text, email.text, telefoon.text, [platformarray objectAtIndex:thePlatformThatIWant]];