iOS实例变量获取";“无效”;不知为什么

iOS实例变量获取";“无效”;不知为什么,ios,xcode,cocoa-touch,nsfetchedresultscontroller,Ios,Xcode,Cocoa Touch,Nsfetchedresultscontroller,我有一个实例变量,如下所示: @property (strong, nonatomic) Post *post; - (id)initWithPageType:(int)pageType andPost:(Post *)post { self = [super initWithNibName:@"StreamViewController" bundle:nil]; if (self) { // Custom initialization self

我有一个实例变量,如下所示:

@property (strong, nonatomic) Post *post;
- (id)initWithPageType:(int)pageType andPost:(Post *)post
{
    self = [super initWithNibName:@"StreamViewController" bundle:nil];
    if (self) {
        // Custom initialization
        self.post = post;
        self.pageType  = pageType;
    }
    return self;
}
我在自定义init方法中设置它,如下所示:

@property (strong, nonatomic) Post *post;
- (id)initWithPageType:(int)pageType andPost:(Post *)post
{
    self = [super initWithNibName:@"StreamViewController" bundle:nil];
    if (self) {
        // Custom initialization
        self.post = post;
        self.pageType  = pageType;
    }
    return self;
}
在这种情况下,它永远不会为NULL。我还有一个带有以下委托方法的
NSFetchedResultsController

- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
   atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
  newIndexPath:(NSIndexPath *)newIndexPath
{
    [...]
    // Here self.post == nil for some reason...
    [...]

有人知道为什么会发生这种情况吗?

编写自己的setter,然后在setter中的语句上设置断点。现在您将知道是什么代码设置了它。

我认为post对象的所有权不知何故已过期,这使它变为零。