我用这段代码来比较两个字符串:
NSComparisonResult result = [cellTitle compare:searchText options:(NSCaseInsensitiveSearch && NSLiteralSearch)];
Run Code Online (Sandbox Code Playgroud)
但是xcode显示有关使用逻辑&&的警告,并且提供按位使用,按位和比较不会返回正确的结果.
我该如何解决?
我正在编码显示一个PHP echo
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init];
[request setTimeoutInterval:180.0];
[request setURL:[NSURL URLWithString:@"http://localhost:8888/MAMP/signup/getkey.php"]];
[request setHTTPMethod:@"POST"];
NSString *key = [[NSString alloc] initWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil] encoding:NSUTF8StringEncoding];
Run Code Online (Sandbox Code Playgroud)
当我编译时,我有这个警告信息: Unused variable key
问题出在哪儿?
为什么Perl会在这种情况下发出警告
Use of uninitialized value `$new` in substitution (s///) at ./perl.pl line 8.
Run Code Online (Sandbox Code Playgroud)
并不是
Use of uninitialized value `$string` in substitution (s///) at ./perl.pl line 8.
#!/usr/bin/env perl
use warnings;
use strict;
my $string;
my $new;
( $new = $string ) =~ s/^.//;
Run Code Online (Sandbox Code Playgroud) 在VS 10中,我收到警告:
warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
Run Code Online (Sandbox Code Playgroud)
试图编译
int x ;
static_cast<bool>(x);
Run Code Online (Sandbox Code Playgroud)
如何编写一个不会引起此警告的代码?
我今天升级到PHP 5.4,我收到一些奇怪的警告:
Warning: Illegal string offset 'quote1' in file.php on line 110
Warning: Illegal string offset 'quote1_title' in file.php on line 111
Run Code Online (Sandbox Code Playgroud)
这些行是代码的这一部分:
for($i = 0; $i < 3; $i++) {
$tmp_url = $meta['quote'. ($i+1)];
$tmp_title = $meta['quote' . ($i+1) .'_title'];
if(!empty($tmp_url) || !empty($tmp_title)) {
$quotes[$src_cnt] = array();
$quotes[$src_cnt]['url'] = $tmp_url;
$quotes[$src_cnt]['title'] = $tmp_title;
$src_cnt++;
}
}
Run Code Online (Sandbox Code Playgroud)
所以$tmp_url和$tmp_title行.
为什么我收到这个奇怪的警告,解决方案是什么?
更新:
此代码用作Wordpress插件.$ meta包括:
$meta = get_post_meta($post->ID,'_quote_source',TRUE);
Run Code Online (Sandbox Code Playgroud)
所以我怀疑只要引号字段为空,就会出现此警告.当字段为空时,有什么方法可以解决这个问题吗?
任何人都有任何想法,为什么它说:
Deprecated: Assigning the return value of new by reference is deprecated in phpExcelReader\Excel\reader.php on line 261
$this->_ole =& new OLERead();
我在用 WAMP - PHP Version 5.3.13
我用过这里的代码:
public Object loadService() throws Exception {
ClassLoader parentClassLoader = ServiceReloader.class.getClassLoader();
ServiceReloader classLoader = new ServiceReloader(parentClassLoader);
Class aClass = classLoader.loadClass("pl.jcubic.Service");
Constructor<?> ctor = aClass.getConstructor(new Class[] { String.class });
return ctor.newInstance(new Object[] { cwd() });
}
Run Code Online (Sandbox Code Playgroud)
(ServiceReloader是一个扩展ClassLoader的类,用于加载文件pl/jcubic/Serice.class)(我的Service类如何两个构造函数一个带有一个参数String和一个null null).
当我调用我得到的代码时:
init.java:40: warning: [unchecked] unchecked call to getConstructor(Class<?>...) as a member of the raw type Class
Constructor<?> ctor = aClass.getConstructor(new Class[] { String.class });
^
where T is a type-variable:
T extends Object declared in class Class
1 warning
Run Code Online (Sandbox Code Playgroud)
我对泛型不是很熟悉,因为当我学习Java时,他们没有被包含在语言中.
我试图放, …
如果我收到Javascript错误,是否可以通知visuel?
在开发中我有Firebug或其他东西打开所以我发现它.但是,如果我为别人做一个轻微的演示,我就不能打开它.
我仍然更喜欢知道错误,而不是默默地失败,我不知道跟踪错误,我无法区分真实错误和尾随错误.
我正在尝试下面的代码,但它给了我警告信息但是当我执行它时运行没有错误.
import javax.swing.JFrame;
class MyFrame extends JFrame {
public MyFrame() {
setTitle("Besm Allah Ya Allah");
setSize(300,300);
setLocation(10,100);
}
public static void main(String[] args){
JFrame f = new MyFrame();
f.show();
}
}
Run Code Online (Sandbox Code Playgroud)
javac -Xlint MyFrame.java 给我:
MyFrame.java:13: warning: [deprecation] show() in Window has been deprecated
f.show();
^
MyFrame.java:3: warning: [serial] serializable class MyFrame has no definition of serialVersionUID
class MyFrame extends JFrame {
^
2 warnings
Run Code Online (Sandbox Code Playgroud)
问题是什么?为什么我收到警告信息?
package morepackage;
public class Subclass extends Superclass {
public static void main (String args[])
{
Superclass t = new Subclass();
System.out.println(t.text);//warning is generated by this line
}
}
Run Code Online (Sandbox Code Playgroud)
该超类包含一个属性文本的静态类型被初始化为字符串"arpan"
超类的代码如下:
package morepackage;
public class Superclass {
static String text = "arpan";
}
Run Code Online (Sandbox Code Playgroud)
代码不会生成编译或运行时错误但是Eclipse给予警告上
行" System.out.println(t.text); "说文本变量应该以
静态方式访问任何人都可以解释原因吗?
warnings ×10
java ×3
iphone ×2
php ×2
xcode ×2
boolean ×1
c++ ×1
casting ×1
deprecated ×1
eclipse ×1
generics ×1
int ×1
ios ×1
javascript ×1
objective-c ×1
perl ×1
reflection ×1
static ×1
string ×1
substitution ×1
swing ×1
variables ×1