Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在单独类中创建的方法返回;“超出范围”;_Iphone_Xcode_Class_Singleton_Methods - Fatal编程技术网

Iphone 在单独类中创建的方法返回;“超出范围”;

Iphone 在单独类中创建的方法返回;“超出范围”;,iphone,xcode,class,singleton,methods,Iphone,Xcode,Class,Singleton,Methods,我已经创建了一个类(NSObject的子类),它将保存我所有的SQLs/dbConnections等 在一个单独的viewcontroller中,我实例化了SQL的类并执行了一些操作,一切都正常 但是。 我在SQL类中的一个方法是定义如下的方法: -(NSString *)queryTable:(NSUInteger *)fieldnum //query from db, and assign the field value into "fieldName" d

我已经创建了一个类(NSObject的子类),它将保存我所有的SQLs/dbConnections等

在一个单独的viewcontroller中,我实例化了SQL的类并执行了一些操作,一切都正常

但是。 我在SQL类中的一个方法是定义如下的方法:

-(NSString *)queryTable:(NSUInteger *)fieldnum
        //query from db, and assign the field value into "fieldName"

        dbEntity = fieldName;
        [fieldName release];

       }
       sqlite3_finalize(statement);
   } 
   return dbEntity;
}
dbEntity定义为NSString,我已将其设置为nonatoimc retain属性

@property (nonatomic,retain) NSString *dbEntity;
当我从viewController中调用此方法并逐步调试时, 我看到该方法正在运行,它正在按预期从数据库查询, 但是当它将值传递到dbEntity时,dbEntity中的值突然“超出范围” 那就是。。。如果我浏览此特定操作:

dbEntity = fieldName; 
我可以在fieldName中看到值,但在dbEntity中看到“超出范围”

为什么

dbEntity定义有什么问题


任何帮助都将被告知。

除非您:

self.dbEntity = fieldName;

如果没有self,您将直接访问变量,但是使用self.dbEntity,您将使用生成的访问方法,这些方法将为您保留非常简单的内容,非常感谢!!