【问题标题】:send a numeric value to a web-service with JSON framework使用 JSON 框架将数值发送到 Web 服务
【发布时间】:2011-05-02 13:00:16
【问题描述】:

发送一个字符串,我把它:

[request setPostValue:choixCommerce forKey:@"ssiphone_commerce"];//choixCommerce is a NSString

没关系,对于数值,我尝试输入:

[request setPostValue:longitude forKey:@"longitude"];//longitude is NSInteger type

但我收到了这个错误:

 incompatible type for argument 1 of 'setPostValue:forKey:'

请问我应该如何发送数值?提前谢谢:)

【问题讨论】:

    标签: web-services json ios


    【解决方案1】:

    您需要输入 NSNumber 而不是 NSInteger :

    [request setPostValue:[NSNumber numberWithInteger:longitude] forKey:@"longitude"];
    

    【讨论】:

    • 嗨,谢谢你的澄清,我想问一下,如果我的经度类型是浮点数而不是 NSInteger,这是否会是同样的工作,或者它将是另一个代码?谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-25
    • 1970-01-01
    • 2011-02-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多