Skip to Content

/wp-content/uploads/2014/09/02_536589.jpg

Hi everyone,

Let’s start with the “store” object.

Store (or more precisely, “ODataStore”) is the common interface and acts as a central access point of the OData service.

In a formal description,

/wp-content/uploads/2014/09/quote_start_537405.pngThe ODataStore is covering exactly one OData service (service document and metadata). It shall be possible for an application to create multiple ODataStores (also in combination on- and offline) at the same time, which shall be completely independent from the API perspective and have own life cycles./wp-content/uploads/2014/09/quote_end_537406.png


So in a nutshell, you have to create the store object in order to CRUD the OData. How do we do it?


Here’s a typical code snippet for online store:


01  SODataOnlineStore *onlineStore = [[SODataOnlineStore alloc]
02                              initWithURL:smpOdataUrl             
03                  httpConversationManager:myConversationManager];
04  [onlineStore setOnlineStoreDelegate:self];
05  [onlineStore openStoreWithError:&error];

Note: I’ll talk about how we create for offline store in later blogs, as the online store is simpler than offline and easier to understand as a first step.


You see the first method name initWithURL:, which is the OData Endpoint URL in SMP server. SMP works as the OData content proxy so once the app gets onboarded to SMP server, SMP should know which URL you need to use. (I’ll also cover the onboarding APIs in another blog)


The second method httpConversationManager: is another interesting new object from the new SDK. While onboarding, we create the HttpConverstationManager, which hides the complexities of HTTP communication – such as headers and credentials.


Once you create the SODataOnlineStore, we need to set the callback methods via SODataOnlineStoreDelegate protocol. For this case, the SODataOnlineStoreDelegate is declared in its own class, so simply set as self.


Okie now we can open the store. Invoke openStoreWithError: and either


  • onlineStoreOpenFinished:

Or

  • onlineStoreOpenFailed: 

Will be called back.


Congratulations, now you have successfully obtained the online store. What’s next…? Yes, CRUD OData.



See you in the next blog,

Ken


List of blogs

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Manjunath Gudisi

    Hi Ken,

    Im following your blogs to create an iOS application for my learning.

    I have few questions on Online and Offline Store.

    – I assume that store is nothing but a database. am I correct?

    – Are there 2 versions of databases (online store and offline store) available on local device?

    – Can I access offline store even when device connected to internet/wi-fi

    – How does sync works for the following. Online Vs Offline, Online Vs Server-database and Offline Vs Server-database

    – I need do CRUD (Create, Remove, Update and Delete) operation on Offline store when device not connected to internet. is it correct?

    Would be great help if you answer my questions. Thanks in advance.

    – Manju

    (0) 
    1. Kenichi Unnai Post author

      Namaskar Manju,

      Sorry for being late. I had been working on H2G upload for you 🙂 You can find loads of H2Gs to accelerate your learning curve – find the links here.

      And I don’t forget to answer your good questions.

      A1. The offline data persisted on the client device is ultimately stored in a database.  But there is a lot of work happening between the application and the database to map OData requests down to the SQL.  It can really be considered as a full OData Producer running on the device whose data store is the ultralite database.

      A2. The online store does not have any database.  An Offline store is actually stored in two ultralite databases files (one with a .udb extension and one with a .rq.udb extension)

      A3 & A4 &A5. – Yup as explained in the later blog – I assume you already caught up with them.

      Hope this helps,

      Ken

      (0) 

Leave a Reply