I’ve been on vacation the last two weeks. It was an experience. Let’s just say that a seven day cruise, the open Pacific Ocean, two cross country flights and an inner ear infection DO NOT MIX!!. My family had a great time, I, however, don’t remember much :-)
My app updates of a couple of weeks ago were 50% successful. One app sailed through review, but the other was rejected. The rejected app crashed on startup. Fortunately, when an app is reviewed because of a crash issue, Apple sends you the crash log. I found out they have made a lot of progress with XCode and how it deploys to the App store. I was able to symbolicate the crash log and figure out that I had two .xib files with the same name in the bundle I submitted for review. The wrong one was getting picked up on the iPad version.
I should have found this in testing, there really is no excuse. I figure what happened was my testing wasn’t deep enough to expose the problem. Even though it wasn’t a section of code I was changing I still somehow introduced this duplicate file while adding new features. I’ll be glad to move these apps to iOS9 so I can use the new UI Testing support.
Progress
Last time I went through the create method of my CloudKit DataService. Today, I’ll talk about the Update method. Here’s the code:
func updateEntity(entity:LocalEntity) {
privateDB.fetchRecordWithID(EntityHelper.remoteRecordID(entity,zoneID: zoneID)){
record, error in
if (error != nil) {
println("error updating entity: \(error)")
}
else {
// Update the record with the changes
EntityHelper.updateRecordWithLocalChanges(record, entity: entity)
// Now save it
self.privateDB.saveRecord(record) {
record, error in
if (error != nil) {
// If we get an error here, I have no idea what to do
println("error updating entity: \(error)")
if let delegate = self.delegate {
dispatch_async(dispatch_get_main_queue()) {
delegate.handleRemoteError(error)
}
}
}
else {
// Now update the local cache
let updatedEntity = EntityHelper.localEntity(record as CKRecord)
if let delegate = self.delegate {
dispatch_async(dispatch_get_main_queue()) {
delegate.entityUpdated(updatedEntity)
}
}
}
// Finally get any other updates we missed
DataService.sharedInstance.getDeltaDownloads()
}
}
}
}
This method takes a LocalEntity and updates the record in the private cloud store. The method accomplishes this by first fetching the record from the private cloud store. In the result block we use the passed in LocalEntity to update the data of the record we just retrieved, using the before mentioned EntityHelper. We next save the record back to the private cloud store. Next we notify the local store delegate the entity has been updated. Finally we retrieve any other updates that have occurred.
The final CRUD method is the delete method. Here is the code:
func deleteEntityWithID(localRecordID: LocalRecordID) {
let recordIDToDelete = CKRecordID(recordName: localRecordID.id, zoneID: zoneID)
privateDB.deleteRecordWithID(recordIDToDelete) {
recordID, error in
if (error != nil) {
println("error saving entity: \(error)")
if let delegate = self.delegate {
dispatch_async(dispatch_get_main_queue()) {
delegate.handleRemoteError(error)
}
}
}
else {
if let delegate = self.delegate {
dispatch_async(dispatch_get_main_queue()) {
delegate.entityDeleted(localRecordID)
}
}
}
DataService.sharedInstance.getDeltaDownloads()
}
}
In this method I create the CKRecordID of the record to be deleted. I ask the private cloud store to delete the record and notify the local store delegate that the entity has been deleted. As in the other methods I take the opportunity to get any other updates that may have occurred.
Reading
I’m in between books right now and determining what to read next. Right now I think it is either going to be “AngularJS In Action” or “Spring Boot In Action”, both from Manning Publishing. I’ll probably start one or both these books this week. It will all depend on what interests me at the moment, web UI, or middle tier.
News
So far, I’ve watched about ten videos from this year's WWDC. I am so impressed at how Apple brings so much to the table each year. Things I’m really excited about are UI testing, code coverage , GameplayKit, CloudKitJS, and of course Swift 2.0. It will be fun diving into all the new changes and technologies.
One thing that continues to strike me as I watched all the new tools and demo’s of iOS9 is how mature the Apple ecosystem is. Each year the integration between the Mac and iOS devices ramps up even more. This year they also amped up the integration between apps with each of the OS’s. Apple has a very compelling user story (if you are willing to live solely in the Apple ecosystem)
No comments:
Post a Comment