Reputation:
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=
Upvotes: 1
Views: 3159
Reputation: 9169
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
Upvotes: 3
Reputation: 69687
As stated in the comment, couldn't you use
[NSString stringWithFormat:@"....%@", uid]
Remember, the %@ will replace an NSString.
Upvotes: 1