我在将UDID传递给xcode中的url时遇到了问题:
[web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://example.com/?udid="+[UIDevice currentDevice].uniqueIdentifier]]];上述方法不起作用。我怎么才能修复它呢?
发布于 2011-06-20 11:00:24
连接在目标C中是不同的。
执行以下操作:
NSString *udid = [UIDevice currentDevice].uniqueIdentifier;
NSString *string = [NSString stringWithFormat:@"http://example.com/?udid=%@",udid];
NSURL *url = [NSURL URLWithString:string];
[web loadRequest:[NSURLRequest requestWithURL:url]];发布于 2011-06-20 11:00:59
你需要正确构造你的URL字符串..."+“不连接Objective-C中的字符串。改用像-stringWithFormat:这样的方法。
发布于 2011-06-20 11:03:22
在Objective-C中不能使用"+“进行字符串连接。它应该是
[NSURL URLWithString: [@"http://www.example.com/?udid=" stringByAppendingString: [UIDevice currentDevice].uniqueIdentifier]]https://stackoverflow.com/questions/6406421
复制相似问题