Re: Instance Variables of NSManagedObject Subclasses

2011-07-01 Thread Jerry Krinock

On 2011 Jun 30, at 15:36, Allen Ingling wrote:

 Am I not supposed to add instance variables to NSManagedObject sublcasses?

There is no problem in adding instance variables to NSManagedObject subclasses. 
 I have done so many times.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Instance Variables of NSManagedObject Subclasses

2011-06-30 Thread Allen Ingling
Dear cocoa-dev list,

I want my NSManagedObjects to retain a variable valid for the lifetime the
application instance but not between instances of the application.  So I
have subclassed NSManagedObject and added an instance variable to the
NSManagedObject subclass and defined a property as follows:

from the NSManagedObject sublcass header file:

   @interface KCBMergingManagedObject : NSManagedObject

{

NSNumber *mergeID;

}

@property(readwrite, retain) NSNumber *mergeID;


and the corresponding .m file contains


   @synthesize mergeID;



Accessing that property has worked but now I have a case where it fails as
follows:


   NSString *foo;

NSString *matchValueTemp;

foo= entityBTemp.mergeID;

   matchValueTemp= [entityBTemp valueForKey: @userTypeName];

   foo= entityBTemp.mergeID;


Here, userTypeName is a field of the entity defined in the core data model
and retain by the context.  At line three of that that snippet the data of
entityBTemp is faulted.  The fault is uniqued by accessing userTypeName in
the fourth line.  In the fifth line, accessing entityBTemp.mergeID causes
the application to crash with EXC_BAD_ACCESS.  The values returned in
variables foo and

matchValueTemp in lines 3 and 4 are  correct.


Am I not supposed to add instance variables to NSManagedObject sublcasses?
 It does seem like a poor idea from the standpoint that it would interfere
with faulting because the data held in the variable and perhaps then
also relationships could not be faulted.  I can not find anything in Cocoa
documentation discussing instance variables in NSManagedObject subclasses.


Is it necessary to define transient attribute in the model to get a volatile
property in a managed object?  Or I could define a new field in the model,
retained between app instances, and clear it at application launch.   I
would like to understand what is going on here though.




Allen W. Ingling
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Instance Variables of NSManagedObject Subclasses

2011-06-30 Thread Allen Ingling
Dear cocoa-dev list,

I want my NSManagedObjects to retain a variable valid for the lifetime the
application instance but not between instances of the application.  So I
have subclassed NSManagedObject and added an instance variable to the
NSManagedObject subclass and defined a property as follows:

from the NSManagedObject sublcass header file:

   @interface KCBMergingManagedObject : NSManagedObject

{

NSNumber *mergeID;

}

@property(readwrite, retain) NSNumber *mergeID;


and the corresponding .m file contains


   @synthesize mergeID;



Accessing that property has worked but now I have a case where it fails as
follows:


   NSString *foo;

NSString *matchValueTemp;

foo= entityBTemp.mergeID;

   matchValueTemp= [entityBTemp valueForKey: @userTypeName];

   foo= entityBTemp.mergeID;


Here, userTypeName is a field of the entity defined in the core data model
and retain by the context.  At line three of that that snippet the data of
entityBTemp is faulted.  The fault is uniqued by accessing userTypeName in
the fourth line.  In the fifth line, accessing entityBTemp.mergeID causes
the application to crash with EXC_BAD_ACCESS.  The values returned in
variables foo and

matchValueTemp in lines 3 and 4 are  correct.


Am I not supposed to add instance variables to NSManagedObject sublcasses?
 It does seem like a poor idea from the standpoint that it would interfere
with faulting because the data held in the variable and perhaps then
also relationships could not be faulted.  I can not find anything in Cocoa
documentation discussing instance variables in NSManagedObject subclasses.


Is it necessary to define transient attribute in the model to get a volatile
property in a managed object?  Or I could define a new field in the model,
retained between app instances, and clear it at application launch.   I
would like to understand what is going on here though.




Allen W. Ingling
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Instance Variables of NSManagedObject Subclasses

2011-06-30 Thread Allen Ingling
Dear cocoa-dev list,

I want my NSManagedObjects to retain a variable valid for the lifetime the
application instance but not between instances of the application.  So I
have subclassed NSManagedObject and added an instance variable to the
NSManagedObject subclass and defined a property as follows:

from the NSManagedObject sublcass header file:

   @interface KCBMergingManagedObject : NSManagedObject

{

NSNumber *mergeID;

}

@property(readwrite, retain) NSNumber *mergeID;


and the corresponding .m file contains


   @synthesize mergeID;



Accessing that property has worked but now I have a case where it fails as
follows:


   NSString *foo;

NSString *matchValueTemp;

foo= entityBTemp.mergeID;

   matchValueTemp= [entityBTemp valueForKey: @userTypeName];

   foo= entityBTemp.mergeID;


Here, userTypeName is a field of the entity defined in the core data model
and retain by the context.  At line three of that that snippet the data of
entityBTemp is faulted.  The fault is uniqued by accessing userTypeName in
the fourth line.  In the fifth line, accessing entityBTemp.mergeID causes
the application to crash with EXC_BAD_ACCESS.  The values returned in
variables foo and

matchValueTemp in lines 3 and 4 are  correct.


Am I not supposed to add instance variables to NSManagedObject sublcasses?
 It does seem like a poor idea from the standpoint that it would interfere
with faulting because the data held in the variable and perhaps then
also relationships could not be faulted.  I can not find anything in Cocoa
documentation discussing instance variables in NSManagedObject subclasses.


Is it necessary to define transient attribute in the model to get a volatile
property in a managed object?  Or I could define a new field in the model,
retained between app instances, and clear it at application launch.   I
would like to understand what is going on here though.




Allen W. Ingling
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com