似乎UIPageViewController永远保存着初始内容视图控制器.例如:
DataViewController *startingViewController = [self.modelController viewControllerAtIndex:0 storyboard:self.storyboard];
NSArray *viewControllers = @[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:NULL];
self.pageViewController.dataSource = self.modelController;
Run Code Online (Sandbox Code Playgroud)
该startingViewController永远不会释放,直到pageViewController它本身释放.
要重现此错误,只需使用基于页面的应用程序模板在XCode中创建一个新项目.并在DataViewController.m中添加3行代码
@property NSInteger debugIndex; // file scope
NSLog(@"DataViewController[%d] created", self.debugIndex); // in viewDidLoad
NSLog(@"DataViewController[%d] dealloc", self.debugIndex); // in dealloc
Run Code Online (Sandbox Code Playgroud)
当您以垂直方向滚动演示应用程序时,您将获得如下日志:
DataViewController[0] created
DataViewController[1] created
DataViewController[2] created
DataViewController[1] dealloc
DataViewController[3] created
DataViewController[2] dealloc
DataViewController[4] created
DataViewController[3] dealloc
DataViewController[5] created
DataViewController[4] dealloc
DataViewController[6] created
DataViewController[5] dealloc
Run Code Online (Sandbox Code Playgroud)
DataViewController [0]永远不会被释放.
有关于此的任何想法?谢谢!
我想写这样的东西:
@interface Foo{
__strong id idArray[];
}
@end
Run Code Online (Sandbox Code Playgroud)
但是编译器抱怨它:
Field has incomplete type '__strong id []'.
Run Code Online (Sandbox Code Playgroud)
如何在ARC下创建id数组成员实例?我如何初始化该数组?使用malloc?新[]?
我不想使用NSArray,因为我正在将一个大型库转换为ARC,这将导致很多工作.
在我的应用程序中,我必须处理来自网络的大量数据并将其解析为优化的本地格式,然后将它们保存到数据库或将其发送到UI(如果有任何UI正在等待该数据).
我知道在主线程中进行大量的解析工作是愚蠢的,因为它会阻塞主线程并使UI交互非常激动.
所以这就是我试图确保UI线程是免费的:
降低所有线程优先级,即
NSOperation.threadPriority=0.1;
NSThread.threadPriority=0.1;
dispatch_async(dispatch_get_global_queue(PRIORITY_LOW));
Run Code Online (Sandbox Code Playgroud)在这两个步骤之后,当在后台线程中完成一些繁重的工作时,UI会更加顺畅,但仍然非常激动.
这个bug看起来像这样:当我滚动一张桌子时非常流畅,突然桌子冻结了大约0.1秒,然后像往常一样顺利地继续.在冻结期间,我可以看到仪器中的CPU爆发.但是在单独的线程视图中,我可以看到主线程正常,几乎没有CPU消耗.