小编Dan*_*Dan的帖子

iOS Calling Web Service不适用于4g

我正在编写一个调用JSON Web服务的应用程序.当iPhone连接到WiFi网络时,它可以正常工作.但是,当它使用蜂窝数据网络时,它不起作用.我收到[NSJSONSerialization JSONObjectWithData:数据选项:kNilOptions错误:&错误]返回的错误.这是我的代码:

-(BOOL) CallService {
    NSError *error;
    NSData *paramData = [NSJSONSerialization dataWithJSONObject:self.parameter    options:kNilOptions error:&error];

    NSString *serviceUrl = [[NSString alloc] initWithFormat:@"%@%@", self.webHost, self.serviceName];
    NSURL *url = [NSURL URLWithString:serviceUrl];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request setHTTPMethod:@"POST"];
    [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [request setValue:@"json" forHTTPHeaderField:@"Data-Type"];
    [request setValue:[NSString stringWithFormat:@"%d", [paramData length]]  forHTTPHeaderField:@"Content-Length"];
    [request setHTTPBody:paramData];
    NSError *errorReturned = nil;
    NSURLResponse *theResponse =[[NSURLResponse alloc]init];
    NSData *data = [NSURLConnection sendSynchronousRequest:request
                                         returningResponse:&theResponse
                                                     error:&errorReturned];

    BOOL retVal = FALSE;

    if (errorReturned){
        //...handle the error
        NSLog(@"%@", errorReturned.description);
    }
    else …
Run Code Online (Sandbox Code Playgroud)

json web-services ios 4g

5
推荐指数
1
解决办法
753
查看次数

WPF Multicolumn Combobox

我有以下用于多列组合框的数据模板:

<DataTemplate x:Key="ShipViaKey">
    <Grid Height="23" Width="Auto" ShowGridLines="False">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Column="0" Text="{Binding Code}"/>
        <TextBlock Grid.Column="1" Text="{Binding Carrier}"/>
    </Grid>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)

组合框的定义如下:

<ComboBox Grid.Row="0" Grid.Column="1" x:Name="CboShipVia" SelectedValue="{Binding FkCarrier, Mode=TwoWay}" SelectedValuePath="PkCarrier" IsEnabled="{Binding HasData}" ItemTemplate="{StaticResource ShipViaKey}"/>
Run Code Online (Sandbox Code Playgroud)

这一切都很好; 除了我只想显示组合框中所选项目的"代码",而不是两个值.有没有办法做到这一点?

wpf combobox multiple-columns

2
推荐指数
1
解决办法
5274
查看次数

标签 统计

4g ×1

combobox ×1

ios ×1

json ×1

multiple-columns ×1

web-services ×1

wpf ×1