Start a new topic

code sample in guides for UiAlertView -> with iOS 9.0 not working anymore

Hi,

you are using following code snippet in the Entities Saving:


let alertView = UIAlertView( title: NSLocalizedString("Save failed", comment: "Save Failed"), message: errorOrNil.localizedFailureReason, //not actually localized delegate: nil, cancelButtonTitle: NSLocalizedString("OK", comment: "OK") ) alertView.show()


however, in iOS 9 -> UIAlertView is deprecated..


 'UIAlertView' was deprecated in iOS 9.0: UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead


I would suggest you change it in your documentation


Thanks for letting us know about this, we will update it soon!


Enjoy your afternoon.

Great..   ;-)

I also recommend that you include an own "Update" bullet point in the guides area..
(saw that already a few people posted on "how to update in iOS"
it just took me about 1 hour on trial & error to figure out, how it really works in Kinvey
(did a query -> got an empty result [] back .. expected an error message...)


 

Peter:


Can you help me understand where the disconnect was for you so we can shore it up?  As is the case with Mongo you need to take an existing entity, update a field, and call a save on it (to write it back to Mongo).   Was there an interaction that was missing or confusing for you?


Thanks,

Hi Damien,


yes.. it was kind of rethinking everything..   coming from Parse.. the error handling is different

and currently I have to reprogram every Parse code I have


this is the original code snippet with parse


let countryQuery = PFQuery(className:"GameCountry")

countryQuery.whereKey("country", equalTo: self.countrySearch)

countryQuery.getFirstObjectInBackgroundWithBlock {

  (gameCountry: PFObject?, error: NSError?) -> Void in

  if error != nil {

     let gameSaveCountry = PFObject(className:"GameCountry")

     gameSaveCountry["country"] = self.countrySearch

     gameSaveCountry["updateDate"] = NSDate()

     gameSaveCountry.saveInBackgroundWithBlock {

        (success: Bool, error: NSError?) -> Void in

        if (success) {

           // The object has been saved.

        } else {

          // There was a problem, check error.description

        }

     }

  } else if let gameCountry = gameCountry {

      gameCountry["updateDate"] = NSDate()

      gameCountry.saveInBackground()

  }

}



I was readying the Database with a query and got an error back, when there was no entry

so I assumed the same for the your Kinvey solution.  

I did not found a Swift code example in the guides area what the return handling is from a query


It's different with Kinvey... when there is no DB entry.. you get back no error however you get as a return back an empty result array:  []


so I just suggest you offer in the guides documentation area, how to handle the result, when there is no entry in the Database..  

(I am probably not the only one changing from parse to your solution)


I solved it this way now.. however it took me some time to figure it out.. instead of having read it quickly in the Guides - section of the iOS documentation


let query = KCSQuery(onField: "country", withExactMatchForValue: self.countrySearch)

self.gameCountryStore.queryWithQuery( query, withCompletionBlock: { (result, errorOrNil: NSError!) -> Void in

  if errorOrNil == nil {

    var gameCountry = GameCountry()

    if result.isEmpty {

       gameCountry.country = self.countrySearch

    }

    else

    {

      gameCountry = result[0] as! GameCountry

    }

      gameCountry.updateDate = NSDate()

      self.gameCountryStore.saveObject(gameCountry, withCompletionBlock: { (objectsOrNil: [AnyObject]!, errorOrNil: NSError!) -> Void in

      if errorOrNil != nil {

      ........

Peter:


That should be an easy enough fix for us to make on our end.   If you run into any other oddities between Kinvey and Parse, please keep us informed.  We are really trying to make this transition as simple and painless as possible for all the developers that are having to Migrate.   


If you have some time for a 15 - 30 minute call when you're fully done with your migration perhaps we could chat about some of the complexities that you ran into during the process?  


Thanks,

sure Damien..


just have another question...  why don't you write  .KCSLessThan


this values with 'k' confused me in the documents:

(maybe it's 


Comparison operators

kKCSLessThan matches where field value is < the supplied value

kKCSLessThanOrEqual matches where field value is <= the supplied value

kKCSGreaterThan matches where field value is > the supplied value

...



Hello Peter,


Sorry about the somewhat slow reply on this (I figured this was a slightly lower priority).


The idea behind kKCS rather than just KCS was due to the fact that the upper-case names typically indicate a class or method.  Where this is just a comparison operator we felt as though this should begin with a lowercase letter to conform to that convention, but it should also have KCS to show the namespace.  


I just spoke with our Director of Mobile Development and he mentioned that he agrees that this is clunky and that he would like to replace it going forward and deprecate the kKCS prefixed functions..  


Please let me know if you have any other issues.  

Hi Damien,


in parse it is possible just to fetch certain fields to minimize the data load over the internet or is always the whole "Object" retrieved from the Database ?

in parse it is called "selectKeys"

I was reading through the guides and was not able to see something similar.


thanks,

Peer

Login or Signup to post a comment