首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将UDID传递给url

将UDID传递给url
EN

Stack Overflow用户
提问于 2011-06-20 10:53:00
回答 3查看 2.1K关注 0票数 0

我在将UDID传递给xcode中的url时遇到了问题:

代码语言:javascript
复制
[web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://example.com/?udid="+[UIDevice currentDevice].uniqueIdentifier]]];

上述方法不起作用。我怎么才能修复它呢?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-06-20 11:00:24

连接在目标C中是不同的。

执行以下操作:

代码语言:javascript
复制
NSString *udid = [UIDevice currentDevice].uniqueIdentifier;
NSString *string = [NSString stringWithFormat:@"http://example.com/?udid=%@",udid];
NSURL *url = [NSURL URLWithString:string];
[web loadRequest:[NSURLRequest requestWithURL:url]];
票数 8
EN

Stack Overflow用户

发布于 2011-06-20 11:00:59

你需要正确构造你的URL字符串..."+“不连接Objective-C中的字符串。改用像-stringWithFormat:这样的方法。

票数 2
EN

Stack Overflow用户

发布于 2011-06-20 11:03:22

在Objective-C中不能使用"+“进行字符串连接。它应该是

代码语言:javascript
复制
[NSURL URLWithString: [@"http://www.example.com/?udid=" stringByAppendingString: [UIDevice currentDevice].uniqueIdentifier]]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6406421

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档