0

I'm using ObjectiveRecord library. There's no problem when use this with Objective-C. But when I use with Swift, maybe it's new to some one, there's problem when I want to create a record to database.

I use Birdging-Header.h with code as below

#import "ObjectiveRecord.h"

When I call as below

var category:Category = Category.create()
category.pkId = 1
category.title = "This is a sample"

At the first line the is error "Ambigious reference to member 'create'".

Is there anyone experience with this error. Please give me advice! Thanks a lot !

Edited:

Detail of Category class

class Category: NSManagedObject {  

    var pkId: NSInteger?  
    var title: NSString?  
    var img: NSString?  
}  

This is Category class.

Edited:

I resolved the problem above, but now I'm facing another problem. This is how to resolve the above

let category:Category = Category.create() as! Category

Now it throw error as below

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an entity named 'Shopping.Category' in this model.'

Is there anyone know how to solve this ?

Trung Bui
  • 188
  • 1
  • 2
  • 13
  • What does the interface look like for `Category`? (Or the Swift equivalent) – Avi Jan 31 '16 at 11:27
  • Please update your question title & content: you now have too many directions, and the question and its title are unclear – SwiftArchitect Feb 01 '16 at 15:50
  • Possible duplicate of [CoreData error: +entityForName: could not locate an NSManagedObjectModel for entity name](http://stackoverflow.com/questions/7100302/coredata-error-entityforname-could-not-locate-an-nsmanagedobjectmodel-for-ent) – SwiftArchitect Feb 01 '16 at 15:51
  • No, it's not my problem. I find a way to solve my problem by add entityForName extension to my NSManagedObject subclass. But there's a lot of things to do with this library in Swift, so I decided back to Objective-C as the best choice. Thanks for your help – Trung Bui Feb 02 '16 at 16:12

0 Answers0