Skip to content

Commit 834582c

Browse files
author
Michele Longhi
committed
User persistence fixed
1 parent 4ec2dfa commit 834582c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CloudBoost/CloudObject.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,11 @@ public class CloudObject: NSObject {
921921

922922
var objectClass: CloudObject.Type
923923

924-
objectClass = CloudApp.objectClassForTableName(tableName)
924+
if let type = type {
925+
objectClass = type
926+
} else {
927+
objectClass = CloudApp.objectClassForTableName(tableName)
928+
}
925929

926930
let object = objectClass.init(tableName: tableName)
927931
object.document = NSMutableDictionary(dictionary: dictionary as [NSObject : AnyObject], copyItems: true)

CloudBoost/CloudUser.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public class CloudUser: CloudObject {
109109
// Save the user if he has been successfully logged in
110110
if(response.status == 200){
111111
if let doc = response.object as? NSMutableDictionary{
112+
self.resetModificationState()
112113
self.document = doc
113114
self.setAsCurrentUser()
114115
}
@@ -363,7 +364,7 @@ public class CloudUser: CloudObject {
363364
if let userDat = def.objectForKey("cb_current_user") as? NSData{
364365
if let doc = NSKeyedUnarchiver.unarchiveObjectWithData(userDat) as? NSMutableDictionary {
365366

366-
let user = CloudUser.cloudObjectFromDocumentDictionary(doc, documentType: T.self)
367+
let user = T.cloudObjectFromDocumentDictionary(doc, documentType: T.self)
367368

368369
self.currentUser = user as? T
369370

@@ -382,6 +383,7 @@ public class CloudUser: CloudObject {
382383
let data = NSKeyedArchiver.archivedDataWithRootObject(self.document)
383384
def.setObject(data, forKey: "cb_current_user")
384385

386+
def.synchronize()
385387
}
386388

387389
public class func removeCurrentUser() {

0 commit comments

Comments
 (0)