GhostEX
V2EX  ›  问与答

这段代码能用 OC 写出来么 在线求大神...

  •  
  •   GhostEX · Dec 31, 2015 · 3126 views
    This topic created in 3989 days ago, the information mentioned may be changed or developed.
    23 replies  •  2015-12-31 16:42:58 +08:00
    babyhome
    babyhome
    Dec 31, 2015
    1
    任何语言都可以写出来啊。。。
    morefreeze
    morefreeze
    Dec 31, 2015
    2
    能
    LMkillme
    LMkillme
    Dec 31, 2015
    3
    @babyhome
    @morefreeze
    楼主问的不是 OC 能不能写出来,是问你们能不能用 OC 把这段代码写下来?
    morefreeze
    morefreeze
    Dec 31, 2015
    4
    felixzhu
    felixzhu
    Dec 31, 2015
    5
    没有对齐看得我好难受。。
    GhostEX
    GhostEX
    OP
    Dec 31, 2015
    6
    @morefreeze 我不信:-D
    Reficul
    Reficul
    Dec 31, 2015
    7
    诶,不会 OC 的表示,这段有啥特别的以至于 OC 不能写?
    GhostEX
    GhostEX
    OP
    Dec 31, 2015
    8
    @Reficul 是我不懂 java ,希望有人能写下 oc 版
    SourceMan
    SourceMan
    Dec 31, 2015
    9
    楼主希望答案是写出来,不是能不能
    sandideas
    sandideas
    Dec 31, 2015 via iPhone
    10
    这就是一个简单的链接吧?
    em70
    em70
    Dec 31, 2015
    11
    伸手党
    Elethom
    Elethom
    Dec 31, 2015
    12
    這種問題需要置頂嗎。請不要濫用置頂功能。

    答案:能。
    unique
    unique
    Dec 31, 2015
    13
    - -!
    wohenyingyu01
    wohenyingyu01
    Dec 31, 2015
    14
    能啊
    lululau
    lululau
    Dec 31, 2015
    15
    没有 close/release 真的不要紧吗
    Kilerd
    Kilerd
    Dec 31, 2015
    16
    伸手党!能写都拒绝!
    wbsdty331
    wbsdty331
    Dec 31, 2015
    17
    @Elethom 估计是铜币多的慌吧
    zzmstring
    zzmstring
    Dec 31, 2015 via Android
    18
    。。。
    0SJViNJF1Dm1pxm0
    0SJViNJF1Dm1pxm0
    Dec 31, 2015
    19
    @Elethom 一小段时间里密集回复也会被置顶的
    morefreeze
    morefreeze
    Dec 31, 2015
    20
    @GhostEX 好吧 你摸牌吧
    LINAICAI
    LINAICAI
    Dec 31, 2015❤️1
    21
    BOOL b;
    @try {
    NSURL *url=[NSURL URLWithString:urlString];
    NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url];
    request.timeoutInterval=30;
    [request setHTTPMethod:@"GET"];
    NSHTTPURLResponse *response=nil;
    NSError *error=nil;
    NSData *data=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    NSInteger a= [response statusCode];
    NSLog(@"ResponseState=%ld",a);
    if (a!=200 || error) {
    NSLog(@"Exception=%@",@"网络错误异常!!!!");
    b = NO;
    }
    else{
    //json 解析
    id json=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
    NSLog(@"请求返回的 json 数据为%@",json);
    //TO DO
    //得到 json
    b = YES;

    }
    }
    @catch (NSException *exception) {
    NSLog(@"调用堆栈=%@",exception.callStackSymbols);
    NSLog(@"Exception=%@",@"这是异常!");
    NSLog(@"Exception=%@",exception.description);
    b = NO;


    }
    @finally {
    return b;
    }
    GhostEX
    GhostEX
    OP
    Dec 31, 2015
    22
    @LINAICAI 谢谢大神。
    LINAICAI
    LINAICAI
    Dec 31, 2015
    23
    说实在的如果 OC 按照楼主你这样写感觉很别扭
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2745 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 48ms · UTC 00:40 · PVG 08:40 · LAX 16:40 · JFK 19:40
    ♥ Do have faith in what you're doing.