• 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
Re: Using an auto incremented NSNumber as attribute in a NSManagedObject
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using an auto incremented NSNumber as attribute in a NSManagedObject


  • Subject: Re: Using an auto incremented NSNumber as attribute in a NSManagedObject
  • From: "Hank Heijink (Mailinglists)" <email@hidden>
  • Date: Thu, 6 Mar 2008 16:12:13 -0500

It's a little busy at the developer website, since they just announced the iPhone SDK. I think there's nothing to do but wait...

Best,
Hank

On Mar 6, 2008, at 4:05 PM, Joshua Preston wrote:

Hey guys,

First, let me say that I'm just starting to pick up Cocoa and Objective-C, and so far, I love it. Core Data seems to be an elegant solution to some of my past problems (mainly Java persistence). I am however having problems finding information regarding auto incremented attributes, namely an NSNumber attribute. I've created the attribute with the Data Modeler and set up all of the relationships I require. Everything worked, so I read about implementing a subclass of NSManagedObject and defining a - awakeFromInsert method. This appears to be working for some of the other fields, such as the date, but I'm having problems determining how exactly to increment the number.

For example, when I create my first object, I want the numeric id field to be 1. Each subsequent insert should be the previous numeric id field + 1. I've read some of the posts regarding performing this and the general thought on this process is to create an additional entity in my data model containing the "current maximum index" then perform fetch, increment and get value of that field and use that for the incremented value of my new object. I'm not sure if this is still the only way or even the preferred way to perform this feat. I'm kind of worried about locking that "counter" field until the new managed object has been created to avoid any increment problems.

Additionally, I've tried accessing the docs located at the link below, but I keep getting connection errors, anyone else having problems accessing the documentation?

http://developer.apple.com/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObject_Class/Reference/NSManagedObject.html

Regards,

Joshua Preston
email@hidden




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
@runbox.com


This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Using an auto incremented NSNumber as attribute in a NSManagedObject (From: Joshua Preston <email@hidden>)

  • Prev by Date: Re: Cocoa - Not loading any window at startup ...
  • Next by Date: Re: CoreAnimation efficiency
  • Previous by thread: Using an auto incremented NSNumber as attribute in a NSManagedObject
  • Next by thread: Re: Using an auto incremented NSNumber as attribute in a NSManagedObject
  • Index(es):
    • Date
    • Thread