GhostEX
V2EX  ›  问与答

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

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

    答案:能。
    unique
        13
    unique  
       Dec 31, 2015
    - -!
    wohenyingyu01
        14
    wohenyingyu01  
       Dec 31, 2015
    能啊
    lululau
        15
    lululau  
       Dec 31, 2015
    没有 close/release 真的不要紧吗
    Kilerd
        16
    Kilerd  
       Dec 31, 2015
    伸手党!能写都拒绝!
    wbsdty331
        17
    wbsdty331  
       Dec 31, 2015
    @Elethom 估计是铜币多的慌吧
    zzmstring
        18
    zzmstring  
       Dec 31, 2015 via Android
    。。。
    0SJViNJF1Dm1pxm0
        19
    0SJViNJF1Dm1pxm0  
       Dec 31, 2015
    @Elethom 一小段时间里密集回复也会被置顶的
    morefreeze
        20
    morefreeze  
       Dec 31, 2015
    @GhostEX 好吧 你摸牌吧
    LINAICAI
        21
    LINAICAI  
       Dec 31, 2015   ❤️ 1
    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
        22
    GhostEX  
    OP
       Dec 31, 2015
    @LINAICAI 谢谢大神。
    LINAICAI
        23
    LINAICAI  
       Dec 31, 2015
    说实在的如果 OC 按照楼主你这样写感觉很别扭
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2636 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 66ms · UTC 16:03 · PVG 00:03 · LAX 09:03 · JFK 12:03
    ♥ Do have faith in what you're doing.