views:

574

answers:

2

Hello,

I have a UIWebView that I need to load a page with a specific URL that pulls a number from the users iPhone.

I have the following code

 UIDevice *myDevice = [UIDevice currentDevice];
NSString *deviceUDID = [myDevice uniqueIdentifier];

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://mysite.com/test.php?uid="]]];

How do I place the "deviceUDID" at the end of "mysite.com/test.php?uid="

Thanks

A: 

As stated in the comment, couldn't you use

[NSString stringWithFormat:@"....%@", uid]

Remember, the %@ will replace an NSString.

casademora
+2  A: 

This can be done a number of ways.

NSString *query = [[NSString alloc] initWithFormat:@"http://mysite.com/test.php?uid=%@", [[UIDevice currentDevice] uniqueIdentifier]];
NSURL *url = [[NSURL alloc] initWithString:query];

Note, if you're looking to simply log the UDID, you don't need to use a webView. You could even just use the following code:

NSString *response = [[NSString alloc] initWithContentsOfURL:url];
if(response)
    //success
else
    //no response from server
Reed Olsen