Array of NSManagedObject attributes
I’d like to get an array of the attributes for my
NSManagedObject so I can use KVO to export them. I can create an array manually and then iterate through it, however, I’d like to get this list automatically, then iterate.
2 Solutions Collect From Internet About “Array of NSManagedObject attributes”
An NSManagedObject has an entity associated with it. Use NSEntityDescription’s
-relationshipsByName. You’ll get a dictionary back from each of those methods. Just ask the dicts for their
Thanks Joshua. Here’s code that I used in case any one would like to see a hard example:
NSString *entityName = NSStringFromClass([myEntity class]); NSEntityDescription *entityDescription = [self entityDescriptionWithEntityName:entityName]; NSDictionary *attributes = [entityDescription attributesByName]; NSArray *attributeNames = attributes.allKeys;
- IBOutlet and IBAction in Swift
- Open a PDF document on iPhone
- ios Title and Subtitle in Navigation Bar centered
- UIWebViewDelegate: webViewDidFinishLoad not called during in-page navigation
- Notification in Swift every day at a set time?
- Can I intercept marker deselect when I tap another marker in Google Maps SDK for iOS?
- Resigning an iOS provisioning profile
- Adding custom objects to object library
- What exactly does the iPhone accelerometer measure?
- iOS Phonegap Infinite Dialog error when running application?
- Fitting annotations on a MKMapView while keeping user position centered
- iOS “thread-id” doesn't group push notifications
- Speed: XML vs. NSUserDefaults
- change uitextview hyperlink color
- Working with Objective-C blocks with Swift