属性未在…对象上找到,错误调试属性在NSManagedObjects上

时间:2022-05-10 20:42:46

I created a new project with objective-c using coredata as so many times before, but I noticed the newer Xcode is not allowing me to debug the properties on my NSManagedObject which refer to another different NSManagedObject.

我用objective-c创建了一个新项目,使用coredata已经有很多次了,但是我注意到新的Xcode不允许我调试NSManagedObject上的属性,它引用了另一个不同的NSManagedObject。

Let me explain with an example. MLP stands for MyLittleProject

让我举个例子来解释。延时代表MyLittleProject

I have the following objects:

我有以下目标:

MLPPerson+CoreDataProperties.h

@property (nullable, nonatomic, retain) MLPCard *card;

MLPCard+CoreDataProperties.h

@property (nullable, nonatomic, retain) NSString *cardID;

when I am in the code and try:

当我在代码中尝试:

NSLog(@“%@“, myPerson.card.cardID);

NSLog(@ % @”,myPerson.card.cardID);

it works great, however when I try to print in the debug console:

它工作得很好,但是当我尝试在调试控制台打印时:

po myPerson.card.cardID

阿宝myPerson.card.cardID

I get an error:

我得到一个错误:

error: property ‘card' not found on object of type ‘MLPPerson *'

错误:在' MLPPerson *'类型的对象上没有找到属性' card'

I am quite confused as this used to work great in older projects I worked on.

我很困惑,因为在我以前做过的旧项目中,它曾经很有用。

1 个解决方案

#1


9  

I found the answer: the reason why this worked before is because the properties were in a class and now they are in a category.

我找到了答案:这之前起作用的原因是属性是在一个类中,现在它们是在一个类别中。

i.e. the content of MLPPerson+CoreDataProperties.h in other projects was part of MLPPerson.h.

即MLPPerson+CoreDataProperties的内容。h在其他项目中是mlpperson的一部分。

Now, to make the debug console print these, you need use

现在,要让调试控制台打印这些,您需要使用

po [myPerson card] cardID]

阿宝[myPerson卡]cardID]

#1


9  

I found the answer: the reason why this worked before is because the properties were in a class and now they are in a category.

我找到了答案:这之前起作用的原因是属性是在一个类中,现在它们是在一个类别中。

i.e. the content of MLPPerson+CoreDataProperties.h in other projects was part of MLPPerson.h.

即MLPPerson+CoreDataProperties的内容。h在其他项目中是mlpperson的一部分。

Now, to make the debug console print these, you need use

现在,要让调试控制台打印这些,您需要使用

po [myPerson card] cardID]

阿宝[myPerson卡]cardID]