使用参数传递URL

时间:2011-09-22 05:09:55

标签: iphone objective-c

我在此NSInteger中传递了一些字符串值和url值的网址,但是当我将breakpoint放在此处并且我在跟踪标签上时,它会显示此消息{{1在exc-bad-access {}}中,我大胆地看到'大胆'我想传递给那里的价值:
url

当我放[ NSInteger day,NSInteger day1,NSString *fromDate1, NSString *fromDate1,NSString *OriginCode,NSString *DestinCode]时,url获得了所有价值,但当我进入breakpoint我的应用崩溃时,为什么会崩溃?帮我。我哪里错了?

breakpoint

3 个答案:

答案 0 :(得分:2)

使你的网址正确如下: -

NSURL *url = [NSURL URLWithString:[*yourstring* stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

答案 1 :(得分:1)

哈里什这将帮助你创建网址检查我们的http://wiki.akosma.com/IPhone_URL_Schemes 像这样

 NSString *template = @"appigotodo://com.example.xyzapp/import?name=%@&note=%@&due-date=%@&priority=%@&repeat=%@";
NSString *name = @"Buy%20some%20milk";
NSString *note = @"Stop%20on%20the%20way%20home%20from%20work.";
NSString *dueDate = @"2009-07-16";
NSString *priority = @"1";
NSString *repeat = @"101";
NSString *stringURL = [NSString stringWithFormat:template, name, note, dueDate, priority, repeat];
NSURL *url = [NSURL URLWithString:stringURL];

[[UIApplication sharedApplication] openURL:url];

答案 2 :(得分:0)

两件事:

  1. 网址包含许多未用作占位符的符号。代码中不在'**'之间的%符号需要像下面那样进行转义:%%。换句话说,SearchInputFRSearchView%24Button应为SearchInputFRSearchView%%24Button

  2. 您正在使用%i将整数放入字符串中。你应该使用%d代替。

相关问题