Populating a UiWebview control with data from a Kumulos API - xcode

I am currently really new to Xcode and the whole Iphone App development but reasonable proficient in Javascript/HTML/SQL.
I am looking at creating a new App which queries its data from a Kumulos database (Kumulos API's).
Before i head down the path, i just want to know if it was possible to query the database(i know how to do this), but more importantly load the returned data into a webview control.
Similar sort of idea as facebook app. I know they use a webview control.
Ive searched, but currently haven't found an answer on how do do this.
Can you suggest a better method?
Excuse my lack of coding examples.

The best way to do this is create objecive-C methods that are called by the javascript in your web view as per this guide:
Calling Objective-C from UIWebView
This way you could call an objective-C function that returns the data loaded from Kumulos, you can then do what you like in the javascript with the loaded data.

Related

Can a Dashboard widget use SQLite data?

I made an iOS app that has my favorite quotes in it by category. I wanted to turn this into a dashboard widget that notifies me of a quote of the day. I've never made a dashboard widget and only read the hello world example on apple site.
Can anyone suggest a good tutorial or help me understand the following:
What is the best way to take my SQLite database of quotes and make it available through a dashboard widget?
Thank you.
Dashboard is, like, really old... it has the look of a technology that's barely clinging to life support.
But if you want to fool around with it anyway, the way to access SQLite from a widget would be to implement a native widget plug-in that uses the SQLite library, exposing methods that your widget JavaScript code can call to fetch the info you need.
Or, as you seem to have done, repackage the data in a different form that you can access more conveniently from widget JavaScript.
I ended up using NerdTools and implemented an awk script to pull a random quote from a text file on my computer. So this was solved a different way.

MvvmCross communication between ViewModels

I am new to MvvmCross and Xamarin. I have been looking into this for some time now and I am trying to find what is the best way to send some data from ViewModel B to ViewModel A. Meaning that ViewModel A is responsible for showing ViewModel B. It's fairly straight forward on how to send data to a ViewModel when launching it, however there is no clearly defined tutorial that I have come across that is showcasing how to send the data back to the starting ViewModel on finishing.
I have come across Event Aggregators like MvvmCross.Messenger that seems to be an ideal candidate. However for an Android project I am not sure if that is a good choice due to Android Activity life cycle methods.
Any help on this would be very well appreciated. Thank you.
The Messenger is the right way to do it, it has been covered in another stack overflow question. There is even a sample code you can toy with.
The gist is that both ViewModel receive a (possibly singleton) Messenger, and when ViewModelB wants to let ViewModelA it needs to reload its data, ViewModelB sends a message through the messenger.
Internally Messenger uses a WeakReference to ensure garbage collection can still go on (check this post for more information)
It sounds like what you want to do is to show a VM for a particular result to be returned to the "parent" VM. This is baked into Android with StartActivityForResult, but needs some hacking to implement with MvvmCross.
Greg Shackles wrote a tutorial on how this can be accomplished. Further discussion here. It's a better fit for the Android activity flow than using the messenger, if I understand your usecase correctly.

View Controller with Multiple sub views

I have a website page which I need to replicate in my app (as a reference for anyone that wants to help the url is http://www.sccgformulary.co.uk/gis.html) There is a title, some sub-headings, plenty of text in different sections and a few different tables. The colouring in the background isn't needed.
My question is how would this be implemented in Interface Builder (if it is even possible?) I don't know how to design the layout of a page which extends further than 1 screen. I've done it before programatically - is this the only way to design views which need a scrollview with multiple subviews? any help would be greatly appreciated!
What you are looking for is probably a simple UITableView with a custom UITableViewCell.
You might need some way of feeding data to your application via a web service. JSON is popular. but before you go ahead I suggest you read up on UITableView and look at some similar Apps to find out exactly what you want.

Cocoa: Core Data + NSTableView

I have a core data app set up, and everything is working pretty well. But there is one little problem. When I insert a new object into my entity I have it go to my NSTableViewCell, where I can edit it to the text I want, but there's one little issue, I can edit the cell, but I can't deselect it to save it to core data, it's stuck in edit mode and the only way I can get out of it is by quitting the application, AND it doesn't save the new name I just gave it in my cell.
This kind of functionality is covered in the Core Data tutorials provided by Apple. It will get you to make use of the NSArrayController which is a very helpful class for synchronising the view (NSTableView) and the model (Core Data).
I believe this is a great place to see how this works: http://developer.apple.com/cocoa/coredatatutorial/index.html
Hope that helps.
What method are you using to connect the table view to the core data store? Bindings? Data Source?
My guess is that you haven't implemented this at all. If you are just getting starting then I suggest implementing an NSTableViewDataSource instance.
http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Protocols/NSTableDataSource_Protocol/Reference/Reference.html

How is AJAX implemented, and how does it help web dev?

From http://en.wikipedia.org/wiki/AJAX, I get a fairly good grasp of what AJAX is. However, it looks like in order to learn it, I'd have to delve into multiple technologies at the same time to get any benefit out of it. So two questions:
What are resources that can help me understand/use AJAX?
What sort of website would benefit from AJAX?
If you aren't interested in the nitty gritty, you could use a higher-level library like JQuery or Prototype to create the underlying Javascript for you. The main benefit is a vastly more responsive user interface for web-based applications.
There are many libraries out there that can help you get benefit out of AJAX without learning about implementing callbacks, etc.
Are you using .NET? Look at http://ajax.asp.net. If you're not, then take a look at tools like qcodo for PHP, and learn about prototype.js, jquery, etc.
As far as websites that would benefit: Every web application ever. :) Anything you interact with by exchanging information, not just by clicking a link and reading an article.
Every website can benefit from AJAX, but in my opinion the biggest benefit to AJAX comes in data entry sections - forms basically. I have done entire sites where the front end - the part the user sees had almost no AJAX functionality in it. All the AJAX stuff was in the administration control panel for assisting in (correct!) data entry.
There is nothing worse than submitting a form and getting back an error, using AJAX you can pretty much prevent this for everything but file uploads.
I find it easiest to just stay away from all the frameworks and other helpers and just do basic Javascript. This not only lets you understand what's going on under the covers, it also lets you do it in the simplest way possible. There's really not much to it. User the JS XML DOM objects to create an xml document client side. Sent it to the server with XMLHTTPRequest, and then process the result, again using the JS XML DOM objects. Start with something simple. Just try sending one piece of information to the server, and getting a small piece of information back.
The Mozilla documentation is good. Sites that benefit from it the most are ones that behave almost like a desktop application and need high interactivity. You can usually improve usability on almost any site by using it, however.
Ajax should be thought of as a means to alter some content on a page without reloading the entire page.
So when do you need to do this? Really only when you have some user interactions or form information that you want to keep intact while you change some content on the page.

Resources