• 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: Populating a new SQLite Core Data store with default data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Populating a new SQLite Core Data store with default data


  • Subject: RE: Populating a new SQLite Core Data store with default data
  • From: Ben Trumbull <email@hidden>
  • Date: Wed, 25 Feb 2009 23:29:46 -0800

After some brief testing, if one creates entities of NSManagedObject thus:

	NSManagedObject *someObject  = [NSEntityDescription insert...];

one most likely cannot use the dot syntax accessors as someObject, during
compilation, has no idea of the attributes of that object an thus an error
will be thrown - it is generic and falls into the "dynamic" category stated
by the documentation.


You'll have to use KVC in that case. At least, I did. I tried both the dot
and standard accessor to be sure.

On 10.5 and later, all NSManagedObjects always respond to methods matching the standard Cocoa conventions for setters and getters for their entity's modeled properties.


If you have a model with an entity that has a "name" attribute, you can just call -name or -setName:. Always.

The ObjC property notation is more of a stickler. You can type cast to a specific subclass. Xcode's Design -> Data Model -> Copy ObjC 2.0 Method Declarations to Clipboard will do all the heavy lifting if you add new properties to your entity. Just select the properties in the data model you want property declaration for.

The only confusion here is that the type declarations have confused the compiler. You ought to be doing:

MySubclass *someObject  = [NSEntityDescription insert...];

- Ben

_______________________________________________

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


  • Follow-Ups:
    • Re: Populating a new SQLite Core Data store with default data
      • From: "Sean McBride" <email@hidden>
    • RE: Populating a new SQLite Core Data store with default data
      • From: "Jon C. Munson II" <email@hidden>
  • Prev by Date: Re: Select tablecell on creation through arrayController
  • Next by Date: Re: renaming a file with special/reserved characters in name
  • Previous by thread: Re: Populating a new SQLite Core Data store with default data
  • Next by thread: RE: Populating a new SQLite Core Data store with default data
  • Index(es):
    • Date
    • Thread