Morning All,
Some of you may be familiar with 'DBAccess' an alternative to CoreData written by Adrian Herridge. It is written in ObjC and whilst I have managed to translate the adding of objects into swift I am having trouble doing the same with queries. Here is the ObjC code:
DBResultSet* r = [[[[[Person query]
where:@"age > 30"]
limit:10]
orderBy:@"surname,forename"]
fetch];
You can check out the framework here:
Thanks in advance,
Jacob
Well, after some investigation it looks like DBAccess does play nicely with Swift but there are some caveats:
Number one, classes seem to need to be defined in a global scope. And not inline within another class (not sure why yet)
Properties bust be dynamic var.
Swift classes must then have an @objc(ClassName) directive added, this allows the original Objective-c code to understand these new objects and inspect them as it previously did.
Here is an example.
@objc(Person)
class Person: DBObject {
dynamic var forename:NSString!
dynamic var surname:NSString!
dynamic var age:NSNumber!
dynamic var favoriteColour:NSString!
}
Hope this helps Jacob.