将'stringWithString:'与文字一起使用是多余的 [英] Using 'stringWithString:' with a literal is redundant

查看:239
本文介绍了将'stringWithString:'与文字一起使用是多余的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ios6中的可达性类中使用了此代码

i used this code in reachability class that is in ios6

   switch (status) {
        case kNotReachable:
            statusString = [NSString stringWithString: @"Not Reachable"];
            break;
        case kReachableViaWWAN:
            statusString = [NSString stringWithString: @"Reachable via WWAN"];
            break;
        case kReachableViaWiFi:
            statusString = [NSString stringWithString: @"Reachable via WiFi"];
            break;
    }

但发生以下错误
使用'stringWithString:'文字是多余的

but the following error is occurred "Using 'stringWithString:' with a literal is redundant"

推荐答案

警告说你可以轻易地这样做:

The warning is saying that you could instead easily do like this:

statusString = @无法访问;

提供的解释是帖子
Obj-C:[NSString stringWithString:@" string"] vs. @" string"

这篇关于将'stringWithString:'与文字一起使用是多余的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆