子类NSManagedObject在NSLog时不调用描述 [英] subclassed NSManagedObject does not call description when NSLog'd

查看:124
本文介绍了子类NSManagedObject在NSLog时不调用描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



每个实体都有一个从NSManagedObject子类化的类。



我得到一个实体的关系集,并且遍历它将每个集合成员转换到特定的子类,因为我枚举了集合。



当我做

  NSLog(@My Entity:% @,myEntityInstance); 

它记录但不调用我的子类的方法:

   - (NSString *)description 

如果我发送:

  NSLog(@My Entity:%@,[myEntityInstance description]); 

任何想法被称为什么,为什么描述必须手动调用?



谢谢!

解决方案

我从来没有见过。我不认为这是一个NSManagedObject行为。您可以在调用之前记录类,以确保您的实例是您认为的类。


I have a data model which has two entities in a relationship of one to many.

Each entity has a class that is subclassed from NSManagedObject.

I get the relation set for the one entity and walk it casting each set member to the specific subclass as I enumerate the collection.

When I do

NSLog(@"My Entity: %@", myEntityInstance);

It logs but does not call my subclass's method for:

- (NSString*) description

It does call if I send:

NSLog(@"My Entity: %@", [myEntityInstance description]);

Any ideas what is being called and why description has to be manually called?

Thanks!

解决方案

I've never seen that. I don't think it's a NSManagedObject behavior. You might log the class before making the call to make sure your instance is of the class you think it is.

这篇关于子类NSManagedObject在NSLog时不调用描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆