0

在我的程序中,我经常需要手动设置一个目标视图控制器,以便我可以用数据填充它。这很好用,但是当我在源控制器和目标控制器之间来回查看 Profiler 时,我的分配量猛增。我正在使用 ARC。我知道这也可能是我在那个目的地设置东西的方式,但我也想知道——当我回到源控制器时,我是否不必摆脱我设置的目标控制器?

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    //Pull which topic the user clicked on from the table view
    NSIndexPath *myIndexPath = [self.myTableView2
                                indexPathForSelectedRow];
    NSArray * topicArray = [[myTopicLoader arrayOfFinishedCategories] objectAtIndex:myIndexPath.section];

    //Create a temporary NSObject Topic to send to the detail view controller
    //Set it to the Topic in the array based on which row the user clicked on
    //(The tableview was populated with the same array)
    topic *tempTopic = [topicArray objectAtIndex:myIndexPath.row];

    //If they clicked on one that has details to show and is purchased, load the detail view controller
    if ([segue.identifier isEqualToString:@"showTopicDetails"]) {
        //Set up a destination view controller
        topicDetailController *topicDetailController = [segue destinationViewController];

        //Set its topic to the temporary one we set up here
        topicDetailController.currentTopic = tempTopic;
    }else {
           //If they clicked on one that does not have details because it is not yet purchased, load
           //the purchase view controller instead
           purchaseDetailController *purchaseDetailController = [segue destinationViewController];

           //And set its topic to the temporary one we set up here.
           purchaseDetailController.currentTopic = tempTopic;


    }

}

我的大部分超额分配是:

29717 0xaa8a600 __NSArrayM 00:28.703.069 • 32 UIKit _UITapRecognizerCommonInit

或者

1069 0x15d5e650 Malloc 32 字节 00:29.254.799 • 32 libsystem_sim_blocks.dylib _Block_copy_internal

我猜这可能来自我正在使用的一些预先构建的东西(书籍控制器和谷歌的 XML 解析器)。但我想检查一下是否可能没有摆脱目标控制器与它有关。

4

0 回答 0