NSString* stradd = [NSString stringWithFormat:@"%s" , sznetadd];
std::string result = ""; //在xcode中调试没有问题,发布审核时会崩溃。日志显示时这里
    Reachability *r = [Reachability reachabilityWithHostName:stradd];
    
    switch ([r currentReachabilityStatus])
    {
        case NotReachable:// 没有网络连接
            result = "";
            break;
            
        case ReachableViaWWAN:// 使用3G网络
            result = "3g";
            break;
            
        case ReachableViaWiFi:// 使用WiFi网络
            result = "wifi";
            break;
            default:
            result = "no Net";
            break;
            
    }
    return result;

解决方案 »

  1.   

    oc,c++混编,厉害了
      

  2.   

    没记错得话,第三行方法reachabilityWithHostName的参数是NSString类型
      

  3.   

    你这行没问题,但是其他地方的C++代码内存管理有问题,review一下代码,找一下空指针和野指针。
      

  4.   

    NSString* stradd = [NSString stringWithFormat:@"%s" , sznetadd];
    sznetadd这个是nil,格式化空对象造成崩溃。
      

  5.   

    别这么做吧,你返回一个NSString就行了,在需要使用STL标准字符串的时候使用这种方式创建:
    td::string *string = new std::string([yourNSString UTF8String]);
      

  6.   

    Reachability *r = [Reachability reachabilityWithHostName:stradd];我记得这个返回类型是NSString类型
      

  7.   

    返回字符串还是返回NSString *比较好,由系统来管理。