-
-
Save dennisschultz-db/c8b33b41a4198aaf6ec7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let picId = packet["pic_id"] as! String | |
let data = packet["data"] as! String | |
let pos = packet["pos"] as! Int | |
let total = packet["size"]as! Int | |
// Initialize picture if this is the first packet | |
if pos == 0 { | |
let timestamp = packet["pic_date"] as! Double | |
picture = Picture(name: picId, date: NSDate(timeIntervalSince1970: timestamp / 1000.0)) | |
} | |
// finalize the picture and call completion handler if this is the last packet | |
if pos == total - 1 { | |
picture.addPacket(data, finalPacket: true) | |
pictureImage.image = picture.getImage() | |
} else { | |
picture.addPacket(data, finalPacket: false) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment