[Ios]swift uses AVOs's API

Source: Internet
Author: User

Avoid writing background code, but to ensure that the app can have backstage, using AVOs this product to help their own app networking, AVOs is a very powerful cloud service, the basic principle and the same as parse, but the parse in foreign countries may be a bit limited to the speed of domestic users.

The following code directly, is a test of the purpose to detect the API and networking speed, and so on.

As long as the data is stored and read.

Equivalent to feeling in the operation of a local database, very convenient, can quickly develop the app.

//avostestvar avobjetctest:avobject = Avobject (className:"Testobject") avobjetctest["Test"]="test2"//inside the bracket is the key to the right is valueAvobjetctest.setobject (NSNumber (int:345), Forkey:"123") Avobjetctest.save ()//This can actually be stored in the background to prevent the main thread from blocking println (Avobjetctest.objectid+"") var avq:avquery= Avquery (className:"Testobject")        //avquery *query=[avquery querywithclassname:@ "Testobject"]//Here is the OC code inside the official documentAvq.wherekey ("Test", Equalto:"test2") Avq.findobjectsinbackgroundwithblock {(objects, er)-Voidinch//Closedpackage here and the official guide is a little different, the left objects here is an object collection type, and the official guide is the Nsarray type, where the specified type is not compiled, and GitHub above the example is not specified type, I can just transform it into a nsarray .            if(Er = =Nil) {println ("#count #", Objects.count) var testarray:nsarray=Objects println (testarray) forObjinchTestarray {var aobj:avobject= obj asavobject println (aobj)}}Else{println (er.userinfo)}}

Too much print, just easy to look at the results, of course, need to operate cocoapods to join the class library, and set up a good swift call OC.

[Ios]swift uses AVOs's API

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.