Comments (6)
This will fix your woes
@objc(MyManagedClass)
class MyManagedClass: NSManagedObject {
}
NSStringFromClass(MyManagedClass)
from objectiverecord.
This could be solved by inspecting the result of NSStringFromClass
, breaking the string up in components separated by .
, and returning the last component.
+ (NSString *)entityName {
NSString *entityName = NSStringFromClass(self);
if ([entityName containsString:@"."]) {
NSArray *components = [entityName componentsSeparatedByString:@"."];
if (components.count > 1) entityName = components.lastObject;
}
return entityName;
}
from objectiverecord.
My work around was to override entityName in a subclass.
On Thursday, February 19, 2015, Bart Jacobs [email protected]
wrote:
This could be solved by inspecting the result of NSStringFromClass,
breaking the string up in components separated by ., and returning the
last component.
(NSString *)entityName {
NSString *entityName = NSStringFromClass(self);if ([entityName containsString:@"."]) {
NSArray *components = [entityName componentsSeparatedByString:@"."];
if (components.count > 1) entityName = components.lastObject;
}return entityName;
}—
Reply to this email directly or view it on GitHub
#115 (comment)
.
from objectiverecord.
I've been struggling with class names in my frameworks as well, here's the solution i came up with:
This is basically NSStringFromClass, but language-independent, which returns class name in objective-c, and second part of class name in Swift(first is module name).
from objectiverecord.
I use Swift 1.2 and XCode 6.3 and I'm still getting the Cannot create an NSPersistentStoreCoordinator with a nil model
error.
Any ideas where I failed? Here's what fails and my steps:
var sample = Sample.create() as! Sample
- Removed obsolete CoreData code from AppDelegate (earlier I have added it manually).
- Created new
xcdatamodeld
named like my project, let's say:MyProject.xcdatamodeld
. - Added new entity
Sample
with few fields and generated a class or it. In entity the configuration I tried bothMyProject.Sample
andSample
as a class. - Tried with with overriding
entityName
and@objc
annotation.
I managed to get such error:
CoreData: error: Failed to call designated initializer on NSManagedObject class 'Sample'
from objectiverecord.
Just popped a swift version.
Cheers!
https://github.com/arkverse/SwiftRecord
from objectiverecord.
Related Issues (20)
- fetching max min and other sql functions HOT 1
- Integrating ObjectiveRecord with iCloud HOT 2
- Swift Example HOT 3
- NSFetchedResultsController HOT 1
- Save completion handler? HOT 1
- Issue with Swift and XCode 6.1 HOT 3
- Sill alive? HOT 1
- Is there a Swift version coming out? HOT 5
- Adding NSPersistentStoreUbiquitousContentNameKey to options dictionary
- Readme - Block based NSPredicate HOT 1
- Testing failed: Use of undeclared identifier '_description'; did you mean 'aDescription'? ** TEST FAILED **
- 64 bit integers on non 64 bit architectures HOT 2
- Carthage error ?
- How should I delete a cascade entity? HOT 1
- Save Only the Object HOT 3
- Sort Methods missing from Pod Version HOT 1
- Possible bug introduced in 1.5 HOT 6
- Find an entity which there is only one entity HOT 4
- Nested objects won't get mapped
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from objectiverecord.