Proyectos de Subversion Iphone Microlearning - Inconcert

Rev

Rev 17 | Rev 19 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 17 Rev 18
Línea 41... Línea 41...
41
 
41
 
Línea 42... Línea 42...
42
        if let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
42
        if let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
43
            
43
            
-
 
44
            let fileURL = dir.appendingPathComponent(Config.DEVICE_UUID_FILENAME)
44
            let fileURL = dir.appendingPathComponent(Config.DEVICE_UUID_FILENAME)
45
            if !FileManager.default.fileExists(atPath: fileURL.path) {
45
            if !FileManager.default.fileExists(atPath: fileURL.path) {
46
                if appData.deviceUuid.isEmpty {
46
                if let new_uuid = UIDevice.current.identifierForVendor?.uuidString {
47
                    if let new_uuid = UIDevice.current.identifierForVendor?.uuidString {
47
                    do {
48
                        do {
48
                        try new_uuid.write(to: fileURL, atomically: false, encoding: .utf8)
49
                            try new_uuid.write(to: fileURL, atomically: false, encoding: .utf8)
49
                        
50
                            
50
                        var sync = SyncModel()
51
                            var sync = SyncModel()
51
                        sync.data = new_uuid
-
 
52
                        sync.type = Constants.SYNC_ADAPTER_TYPE_DEVICE
-
 
53
                        
-
 
54
                        let syncDao = SyncDao()
-
 
55
                        if syncDao.insert(record: sync) > 0 {
-
 
Línea -... Línea 52...
-
 
52
                            sync.data = new_uuid
-
 
53
                            sync.type = Constants.SYNC_ADAPTER_TYPE_DEVICE
-
 
54
                            
-
 
55
                            let syncDao = SyncDao()
-
 
56
                            if syncDao.insert(record: sync) > 0 {
56
                            appData.deviceUuid = new_uuid
57
                                appData.deviceUuid = new_uuid
57
                            appData.save()
58
                                appData.save()
58
                            
59
                                
-
 
60
                                let syncAdapter = SyncAdapter()
59
                            let syncAdapter = SyncAdapter()
61
                                syncAdapter.sync(isForeground: true) {
60
                            syncAdapter.sync(isForeground: true) {
62
                                    success in
-
 
63
                                }
-
 
64
                            }
-
 
65
                        }
-
 
66
                        catch {/* error handling here */}
-
 
67
                    }
61
                                success in
68
                } else {
62
                            }
69
                    do {
63
                        }
70
                        try appData.deviceUuid.write(to: fileURL, atomically: false, encoding: .utf8)
64
                    }
71
                    }
65
                    catch {/* error handling here */}
72
                    catch {/* error handling here */}