小编ssg*_*reg的帖子

使用swift中泛型类派生的类的限制

我试图从泛型类派生我的类:

class foo<T> {}
class bar : foo<Int> {}
Run Code Online (Sandbox Code Playgroud)

但是此代码无法使用en错误进行编译:

从泛型类派生的类也必须是通用的

如何避免这种限制?可能吗?

generics class swift

34
推荐指数
4
解决办法
1万
查看次数

Xcode Beta3中的CMutablePointer和CConstPointer发生了什么?

Xcode Beta3中的CMutablePointer和CConstPointer发生了什么?

在Beta2中成功编译的代码失败并显示错误:

Use of undeclared type 'CMutablePointer'
Run Code Online (Sandbox Code Playgroud)

beta xcode swift

3
推荐指数
1
解决办法
1037
查看次数

ARC已启用.为什么'dealloc'方法不调用?

ARC已启用.为什么'dealloc'方法不调用?我应该在这里使用@autoreleasepool吗?为什么?谢谢.

@interface Test : NSObject
@end

@implementation Test

+(id)testFromNothing
{
  id res = [Test alloc];
  return res;
}

-(void)dealloc
{
  NSLog(@"deallocated");
}

@end


int main(int argc, const char * argv[])
{
  Test* test = [Test testFromNothing];
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

memory objective-c automatic-ref-counting

1
推荐指数
1
解决办法
270
查看次数