INDIA

Site No. 15, Phase 1, Rajiv Gandhi Technology Park,
Chandigarh UT 160101

Email info@netsolutionsindia.com

Phone +91 172 431 5000

Location View in Google Maps

UK

86-90 Paul Street
London EC2A 4NE

Email info@netsolutionsuk.com

Phone +44 (208) 004 6688

LocationView in Google Maps

USA

27, Sunset Avenue
Venice, CA, 90291

Email info@netsolutionsus.com

Phone +1 (323) 553 3638

Location View in Google Maps

Get in Touch
Get in Touch

We’d love to hear from you.

menu
Contact Us

How CMLibrary developed by Net Solutions speeds up iOS apps for you?

As you would probably know, a lot of code programmers write is re-usable. Small parts of such code are known as snippets and several snippets can be combined to form a library. Snippets and libraries of re-usable code help avoid rework each time a new program or application is written as you can insert snippets instead of rewriting code.

At Net Solutions, we build iOS applications often. Most of those who build such apps use web services to send and retrieve data. Adding such functionality to the apps means having to write a lot of code over and over again, unless you create snippets or even a library of re-usable code. That is how the idea for CMLibrary or content management library came up.

It lets you insert 4-5 lines of code instead of rewriting 15-20 lines each time you enable an iOS app to send and retrieve data through web services. You can download and upload large-sized files or content with memory efficiency. CMLibrary also allows for caching of information.

In what ways CMLibrary is really unique?

CMLibrary provides ease of use and memory efficiency and there are no memory leaks. The library supports JSON and XML, among other formats. That is why this Arc-based library stands out among the mostly manual-based libraries available in the market.There are other such libraries available in the market. However, most of those are not for free or not memory efficient.

How does CMLibrary help delivering apps faster?

  • The library speeds up the process of building iOS apps.
  • The technology is fast, memory-efficient and not prone to memory leaks.
  • It supports caching.
  • It helps large amounts of data travel between the app and the server without glitch, thus improving the UI and UX of the apps.
  • The library supports data formats such as JSON, XML, etc.

The problem that this technology solves – Real-world examples

In most iOS-app projects, you have to use web services to get data from and post data to a server. Simply put, you have to write code in all the classes where data comes from the server. If there are many formats in use in the project, such as JSON and XML, you have to write different code for the same purpose for each of the different types.

You have to add the following in each class to reach the web service and get a response:

// Create the request

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://google.com"]];

// Create url connection and fire request

NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];

//NSURLConnection Delegate Methods

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {

// A response has been received, this is where we initialize the instance var you created

// so that we can append data to it in the didReceiveData method

// Furthermore, this method is called each time there is a redirect so reinitializing it

// also serves to clear it

_responseData = [[NSMutableData alloc] init];

}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {

// Append the new data to the instance variable you declared

[_responseData appendData:data];

}

- (NSCachedURLResponse *)connection:(NSURLConnection *)connection

willCacheResponse:(NSCachedURLResponse*)cachedResponse {

// Return nil to indicate not necessary to store a cached response for this connection

return nil;

}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {

// The request is complete and data has been received

// You can parse the stuff in your instance variable now

}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {

// The request has failed for some reason!

// Check the error var

}

In CMLibrary, you don’t have to use these delegate methods in each class. You just have to add the following in a class:

WebserviceCall *webserviceCall = [[WebserviceManager sharedInstance] getWebserviceCallObjectWithDelegate:self withResponseType:WebserviceCallResponseJSON cachePolicy:WebserviceCallCachePolicyRequestFromUrlNoCache];

[webserviceCall setPostDataDict:DataDict];

[[WebserviceManager sharedInstance] callWebserviceForSignInWithSuccessSelectorNotification:@selector(onWebserviceSuccess
Notification:) failureSelectorNotification:@selector(onWebserviceFailureNotification:) webserviceCall:webserviceCall];

You can use the following two methods to receive a response:

-(void)onWebserviceSuccessNotification:(NSNotification *)notification

{

//Contain the response data

}

-(void)onWebserviceFailureNotification:(NSNotification *)notification

{

//Show alert when some error is there

An example from an app we are working on :

Given below is a screenshot from an app known as EdPlace that we are working on. It is an education-related app and is meant to help students with subjects including mathematics.

CMLibrary
In the given example, data for ‘level’, ‘date’, etc. is being fetched from a server using web service through CMLibrary. The caching function is also operational here and proves helpful if a user moves away from this screen and then returns to it.

Besides developers, how does CMLibrary benefit end-users

The technology facilitates large amounts of data traveling to and fro between the server and the app. So, this technology helps end-users as the user interface continues to function properly while substantial data is being fetched from or posted to the server, thus improving the user experience of the apps using CMLibrary.
Have you developed or benefited from such a technology before? Let us know in the comments section below.

Summary
Article Name
How Net Solutions’ CMLibrary speeds up iOS apps for you
Author
Description
This blog post is about a code library Net Solutions has developed to make iOS apps fetch information faster through web services.
About the Author
Aditya Aggarwal
Aditya Aggarwal is a Project Leader in the iOS Application Development team at Net Solutions and has around four years of experience in Web, Desktop and Mobile app development. He is keen to learn new technology, loves to face challenges and handle them very efficiently. Besides being a hard worker he is a smart worker too. In the leisure time he use to watch movies, spend time with his family and explore new places

One thought on “How CMLibrary developed by Net Solutions speeds up iOS apps for you?

  1. Vikas on said:

    Good Work Sir,..Caching of the data in the library gives new edge to the application.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Are you planning to build a web or mobile based solution?

  • Get Regular Updates

  • Popular Posts