mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-13 23:23:29 +01:00
Bridge with objc project #326
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @paoloandrea on GitHub (Apr 22, 2020).
Hi, i've a project mixed swift/objc.
I using CoreStore in my Swift classes but I cannot understand how to mix the objc classes.
I need to import the CoreStore in my classes and after call the swift data stack make: fetch, save, delete.. etc
How to mix the project?
I know the information about the deprecate classes for objc, but my project is very big and i cannot transform all classes in swift.
Swift Stack code
`
@objc open
class Database:NSObject {
@objc public
//Stack for Objc
static let objcStack = CSDataStack.init(Database.stack)
}
`
This is my objec-c code:
`
#import "TestController.h"
@import CoreStore; //<- ERROR --- needed call the CoreStore Classes? How to call it?
@implementation TestController
[super viewDidLoad];
[Database objcStack] // how to execute function like fetch, save, delete.. etc????
//Do you have many example??
}
@end
`
Thanks for help me.
@JohnEstropia commented on GitHub (Apr 23, 2020):
See: https://github.com/JohnEstropia/CoreStore#objective-c-support
@paoloandrea commented on GitHub (Apr 23, 2020):
Hi JohnEstropia, thanks to your answer. :)
Can you write me if this process is ok?
MyPersonEntity is my NSManagedObject class
in the top class:
@import CoreStore;in Class file
`[CSCoreStore beginAsynchronous:^(CSAsynchronousDataTransaction transaction) {
CSFrom fromMyPersonEntity = CSFrom alloc] initWithEntityClass:[MyPersonEntity class;
If this is not ok, can you explain me how to do this?
Another problem
In your example you can use CSFromClass like this:
CSFromClass([MyPersonEntity class])];But in my code Xcode found a Mistake and doesn't compile.
To make the same work I need to make
[CSFrom alloc] initWithEntityClass:[MyPersonEntity class]];How the Xcode can send this error? I need to import other CoreStore classes
Can I only use class allocation (CSFrom) to obtain the CSFromClass?
@JohnEstropia commented on GitHub (Apr 24, 2020):
Your
beginAsynchronoususage seems fine. Are you having problems with it?As for
CSFromClassnot compiling, what errors are you getting?@paoloandrea commented on GitHub (Apr 24, 2020):
Hi John I've two different error:
And now I found another problem.
i start my database like your example:
If I call the fetchOne or FetchAll in my other controller or NSObject class, to find the Entity the app crash
I use this function to fetch
Database.stack.fetchAll(From< Entity >())I'm outside the main thread. ???
How can solve it???
Thank's for all your support.