null

Can someone explain “Dereference of a null pointer” warning

﹥>﹥吖頭↗ 提交于 2020-01-25 10:01:09
问题 I've written a couple of apps which work and seem bug free (ie, they don't crash...) but I get warnings for the code below (which I use a few times) - In the @interface - GameViewController *controller; In the @implementation - -(id)initWithOwner:(GameViewController *)aController withName:(NSString *)manName { if (self = [super init]) { // do stuff } controller = aController; On that last line, it says "Dereference of a null pointer". I'm fairly new to Objective-C (and C as well) so I haven't

attempt to compare nil with number Corona

戏子无情 提交于 2020-01-25 07:12:57
问题 I'm about to finish my game, but I ran into an error: attempt to compare nil with number game2.lua 444 I don't have a clue on how to fix this, and I've tried quite everything, with no success. I think the function scrollSpace is causing this, because sometimes the background would scroll at an uncontrollable speed. Here is my code: function scrollSpace(self,event) if self.x < -900 then self.x = 800 else self.x = self.x - self.speed end end This controls how the stuff scroll across the screen.

attempt to compare nil with number Corona

故事扮演 提交于 2020-01-25 07:12:17
问题 I'm about to finish my game, but I ran into an error: attempt to compare nil with number game2.lua 444 I don't have a clue on how to fix this, and I've tried quite everything, with no success. I think the function scrollSpace is causing this, because sometimes the background would scroll at an uncontrollable speed. Here is my code: function scrollSpace(self,event) if self.x < -900 then self.x = 800 else self.x = self.x - self.speed end end This controls how the stuff scroll across the screen.

C strchr works with NULL value on HPUX but segfaults on RHEL

时间秒杀一切 提交于 2020-01-25 06:52:49
问题 I'm moving some code from HPUX 11.11 to RHEL 7.5 and it includes a function that uses strchr. On HPUX it runs fine, and on RHEL there is a segmentation fault. I isolated the code and created the following simple test, with the subsequent results. It looks like HPUX strchr is returning an empty string rather than NULL when the character is not found. This is not what the man page says. I have found it might not be the strchr function but the difference in how HPUX handles NULL values, or a

Sparse Matrix in AMPL

天涯浪子 提交于 2020-01-25 03:53:26
问题 I have a sparse matrix in AMPL. As a result, it includes a lot of values that are coded as ".". The "." value in AMPL means "no value specified here." When I try to solve the optimization problem I get a message reading "no value specified for..." in reference to the cells containing the "." consequently, it won't solve the problem. However, when I try to specify a default value to replace the ".", the problem churns and churns and doesn't solve. Is there any way I can set restrictions on the

jdbc通过PreparedStatement批量写人mysql方法

瘦欲@ 提交于 2020-01-25 02:46:28
我们如果使用PreparedStatement批量写入一些数据用于我们的MySQL各种测试呢我们来看了方法1 public void test11 ( ) { Connection conn = null ; PreparedStatement pstm = null ; ResultSet rs = null ; try { conn = JDBCUtils . getConnection ( ) ; String sql = "insert into goods (name) values(?)" ; pstm = conn . prepareStatement ( sql ) ; for ( int i = 35860 ; i <= 25335860 ; i ++ ) { pstm . setObject ( 1 , "今日订单_*" + i + "_条目。***" ) ; pstm . executeUpdate ( ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } finally { //这里写关闭操作。 } } 此方法虽然简单,但是对于性能方便不是特别好,我们做IO的时候大家应该知道有个缓存的概念吧。 同样我也可以通过用缓存的方式不要每循环一次就写入一条,我们可以缓存N条记录以后,一次性写入。

T-SQL语句对表的管理(综合)

别来无恙 提交于 2020-01-25 00:07:40
1.创建student_dept表 use XS GO create table student_dept ( sno char ( 16 ) not null primary key , sname char ( 8 ) null , sage int null , ssex char ( 12 ) null , sdept varchar ( 30 ) null , ) 2.为表student_dept插入数据行 use XS GO insert into student_dept values ( '000101' '王东' 20 '男' '计算机' ) 3.将物流管理专业的学生的专业改为市场营销 use XS GO update student_dept set sdept = '市场营销' where sdept = '物流管理' 4.将每个学生的年龄减少4岁 use XS GO update student_dept set sage = sage + 4 5.删除指定学号的学生信息 use XS delete student_dept where sno = '000202' 6.创建视图view_grade,查询所有男生的学号和姓名 use XS GO create view view_grade as select sno,sname from student

rails tutorial: cookie doesn't match remember token

余生长醉 提交于 2020-01-24 22:45:52
问题 I am doing Michael Hartl's Rails Tutorial Chapter 8. When I try to find a user by remember_token stored in the browser cookie it isn't working. The find_by method returns NIL. I have been trying to debug by looking at the remember token cookie stored on the browser and comparing it to the remember token stored in the user database. They don't match and I don't know why. Here is the code for the Session Helper. module SessionsHelper def sign_in(user) remember_token = User.new_remember_token

Active Resource return nil object

↘锁芯ラ 提交于 2020-01-24 20:04:54
问题 I try to use active resource with a server where I can see log. I request the server with a show on a order with xml. class Orders < ActiveResource::Base self.site = "http://"+Hello::Services.session.server+"/api/" self.element_name = "orders" self.format = ActiveResource::Formats::XmlFormat end o = Hello::Services::Orders.find(o.id) When I look what he returns he sends me the correct object in xml. but when I look what I receive with this: puts "====:" puts xml puts xml.inspect the second

Changing NULL's position in sorting

倖福魔咒の 提交于 2020-01-24 15:57:05
问题 I am sorting a table. The fiddle can be found here. CREATE TABLE test ( field date NULL ); INSERT INTO test VALUES ('2000-01-05'), ('2004-01-05'), (NULL), ('2008-01-05'); SELECT * FROM test ORDER BY field DESC; The results I get: 2008-01-05 2004-01-05 2000-01-05 (null) However I need the results to be like this: (null) 2008-01-05 2004-01-05 2000-01-05 So the NULL value is treated as if it is higher than any other value. Is it possible to do so? 回答1: Easiest is to add an extra sort condition