• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Unexpected NSManagedObject isInserted behavior in iPhone.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Unexpected NSManagedObject isInserted behavior in iPhone.


  • Subject: Unexpected NSManagedObject isInserted behavior in iPhone.
  • From: Erwin Hogeweg <email@hidden>
  • Date: Sun, 16 Aug 2009 09:37:22 -0400

All-

First of all, I am not sure this is the right place to post this question, but I didn't see a one for iPhone or Core Data, so bear with me.

I ran into an issue with managed objects, and I am not even sure whether this is expected iPhone SDK (3.0) behavior, or a user error. Please refer to the code below.

The issue is that I don't expect the isInserted flag to have changed when viewWillDisappear is called. I hit the navigation back button as soon as the view appears, no additional code is executed. It is almost as if I am looking at a different object, but the object references in viewDidLoad and in viewWillDisappear are the same.

I have read the Core Data Programming Guide, and the Class References documentation, but I am obviously still be missing something.

Can somebody please shed some light on this?

Any help is highly appreciated.

Regards,

Erwin

-(void)viewDidLoad{
[super viewDidLoad];
...
MyObject *newObject = [NSEntityDescription insertNewObjectForEntityForName:@"MyObject" inManagedObjectContext:managedObjectContext];
myObject = newObject; // Added to inspect oject reference
[myObject retain];
NSLog(@"viewDidLoad - isUpdated: %d", [myObject isUpdated]);
NSLog(@"viewDidLoad - isInserted: %d", [myObject isInserted]);
[myObject setSomeAttribute:[NSDate date]];
...
}

-(void)viewWillAppear:(BOOL)animated{
NSLog(@"viewWillAppear");
}

-(void)viewWillDisappear:(BOOL)animated{
NSLog(@"viewWillDisappear - isUpdated: %d", [myObject isUpdated]);
NSLog(@"viewWillDisappear - isInserted: %d", [myObject isInserted]);   // Expect this to be TRUE
...
}

2009-08-16 08:28:36.287 CDTestApp[18000:20b] viewDidLoad - isUpdated: 0
2009-08-16 08:28:36.297 CDTestApp[18000:20b] viewDidLoad - isInserted: 1
2009-08-16 08:28:36.305 CDTestApp[18000:20b] viewWillAppear
2009-08-16 08:28:42.777 CDTestApp[18000:20b] viewWillDisappear - isUpdated: 0
2009-08-16 08:28:42.778 CDTestApp[18000:20b] viewWillDisappear - isInserted: 0   <----- expected this to be 1


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Unexpected NSManagedObject isInserted behavior in iPhone.
      • From: Erwin Hogeweg <email@hidden>
  • Prev by Date: Recommendations for strip(1)? Was: gdb: "No line number info...."
  • Next by Date: Re: ld errors when Cocoa app linking C++ via intermediate ObjC++ library
  • Previous by thread: Re: Recommendations for strip(1)? Was: gdb: "No line number info...."
  • Next by thread: Re: Unexpected NSManagedObject isInserted behavior in iPhone.
  • Index(es):
    • Date
    • Thread