在更新我的一些代码以与iOS 5 SDK兼容时,我试图通过在Xcode中使用"转换为Objective-C ARC"来重构我的代码并收到错误.我的.h文件中的实例变量发生错误.
NSError **_error;
Run Code Online (Sandbox Code Playgroud)
错误显示"指向非const类型'NSError*',没有明确的所有权." 我该如何解决这个问题?
在更新下面的代码以使用iOS 5的自动引用计数时,在尝试执行快速枚举时为"state-> itemPtr"分配缓冲区时发生错误,以便可以使用"foreach"循环迭代实现类.我正的错误是"分配'__autoreleasing ID*’到'__unsafe_unretained标识*’的变化保留指针/释放属性".查看带注释的代码行.
/*
* @see http://cocoawithlove.com/2008/05/implementing-countbyenumeratingwithstat.html
* @see http://www.mikeash.com/pyblog/friday-qa-2010-04-16-implementing-fast-enumeration.html
*/
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState *)state objects: (id *)buffer count: (NSUInteger)bufferSize {
NSUInteger arrayIndex = (NSUInteger)state->state;
NSUInteger arraySize = [_tuples count];
NSUInteger bufferIndex = 0;
while ((arrayIndex < arraySize) && (bufferIndex < bufferSize)) {
buffer[bufferIndex] = [_tuples objectAtIndex: arrayIndex];
arrayIndex++;
bufferIndex++;
}
state->state = (unsigned long)arrayIndex;
state->itemsPtr = buffer; // Assigning '__autoreleasing id *' to '__unsafe_unretained id*' changes retain/release properties of pointer
state->mutationsPtr = (unsigned long *)self;
return bufferIndex; …Run Code Online (Sandbox Code Playgroud) 在SQLite中是否有PRAGMA table_info('mytable')的等效SELECT语句?基本上,我想获得与PRAGMA返回完全相同的结果集:cid,name,type,notnull,dflt_value和pk.虽然我知道通过C函数sqlite3_table_column_metadata获取此信息的另一种方法,但我更喜欢使用SELECT语句.