hi all,
i would like to create my CBLModels in the view layer and persist them
later in the database.
Referring to the CBLModel.h documentation
<https://github.com/couchbase/couchbase-lite-ios/blob/master/Source/API/CBLModel.h#L37>
the *init *initializer seems to was intended for that:
/** Creates a new "untitled" model object with no document or database at all
yet.
Setting its .database property will cause it to create a CBLDocument.
(This method is mostly here so that NSController objects can create
CBLModels.) */
- (instancetype) init;
When i'm instantiating and setting a value of a detached model the
following exception is thrown:
*MYModel setValue:ofProperty:],
/Users/jenkins/jenkins/workspace/build_cblite_ios_100/couchbase-lite-ios/Source/API/CBLModel.m:447**<unknown>:0:
error: -[MYView viewDidLoad] : failed: caught
"NSInternalInconsistencyException", "Invalid parameter not satisfying:
_document"*
*MYView.swift*
public class MYView : UIView {
override func viewDidLoad() {
//Init manager/db
var manager : CBLManager = CBLManager.sharedInstance()
var database : manager.databaseNamed("mydb", error: nil)
//Create model
var model : MYModel = MYModel()
//!!!Exception!!!
model.name = "somename"
model.database = database
}
}
*MYModel.h*
#import "CBLModel.h"
@interface MYModel : CBLModel
@property (copy) NSString* name;
@end
*MYModel.m*
#import "MYModel.h"
@implementation MYModel : CBLModel
@dynamic name;
@end
What am i doing wrong?
Thx for your help!
*Xcode6*
*couchbase-lite-1.0.0*
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/c61e3548-99f5-47d6-9712-c858458f92ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.