How can I populate a TableView in swift - tableview

So I am making an iOS app and it allows users to submit random entry’s to the member, it’s sort of like the Yolo app in many ways.
Now I have a web service setup to retrieve the data using HTTP POST requests and depending on the provided variables it will return the information it’s looking for.
I have no idea how I’m supposed to use a HTTP POST request to populate a UITableView in Swift. Can anyone help me out here, I’ve tried several times and several ways!
If it matters the two variables I need are
type=X&identifier=y
NOTE: I AM NOT USING UITableView, I’m using the TableView within the View Controller

Related

Multiple Shells (views and view models) and routers for different type of users in Durandal

So I'm trying to build an app that has two different kind of users, namely customers and sellers. The app is designed in such a way that both of them will have different kind of navigation bars and access to different kind of pages via routes. As such, I'm trying to see what is the best way to achieve this? I'm thinking of either of the following solutions:
1. using compose binding or areas in my shell.html and by having a container and based on a certain condition, the correct specific view (partial view)will be injected and the default binding context will be a common shell.js. However, the nav bar and each navigation panel displayed is determined by the routes that have
nav:true
and both seller and customer will have different routes that are marked nav:true. Is there a way to work around this limitation if we use this approach?
2. using compose binding but having two different views and viewmodels that we bind to our shell.html and shell.js. In other words, there will be two routers. However, I've read a number of posts about having two routers and apparently having multiple main routers in an app is not suggested. Is there another way I should approach this?I was having thinking of having multiple SPAs but I figure that would not be efficient since this is a mobile app. Any help or suggestion is greatly appreciated!
You could simply develop two separate SPAs, but have them share much of the same codebase. With this approach, there's nothing special going on, other than your responsibility to modularize your code for reuse.
This approach would also eliminate the need to incorporate extensive logic throughout to curtail, trim, or augment the web app based on the user currently logged in.

How to have 1 controller for 2 segues in Xcode

i have one simple question. I am building an app in Xcode 5. Part of the app is the typical login screen and the register screen and a database which stores username and password. My problem is that i don't want to write Sqlite code in both screens (in both view's controllers). What i want is to have the "databaseViewController.h and .m" controlling both the login controller and register controller. My question is : How do i do that? Im not asking for code, but short similar examples would be very helpful!. I am using storyboards if that helps too
What i want is to have the "databaseViewController.h and .m" controlling both the login controller and register controller
A common approach is to move the data access stuff out of your view controllers and into a data model (that's the M in MVC) that both view controller can talk to. Your model would have method to log in, register, tell you whether the user is already registered, etc. That leaves your view controllers to do what they do best: manage their respective view graphs and deal with user input. Maybe you already have some sort of data model, in which case the user registration and login functions can just be added to it. Otherwise, have your app delegate set up your model when the app starts up and share it with the view controllers that need to know about it.
To answer your question indirectly: If your goal is simply to share code between these two screens, you may find it easier to extract that code into a separate class, like AuthenticationManager or something, which you then use from your two different view controllers.
One common pattern for shared service objects like this is to hang them off of your application delegate. That is, add a property (e.g. authManager) to AppDelegate and then in your view controller(s), access it as [UIApplication sharedApplication].delegate.authManager.

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.

Populating a UiWebview control with data from a Kumulos API

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.

displaying web pages over web views in collection view using cocoa bindings

I tried sample example given at this link - Collection View Programming Guide
It is simple and it worked. Considering it as a reference I tried a simple application which will show a collection view of web views with some web page displayed over each web view.
The model class has two properties: NSString *pageName, and NSURL *pageURL.
I then followed each and every step written in tutorial above with required modifications but I was caught in the step -
How to bind web view to collection
view item?
In binding tab it shows three possibilities : Editable, Hidden, Tool tip but none of these is working.
Can anyone suggest me way to accomplish my requirement?
Thanks,
Miraaj
WebView does not expose bindings for the URL (one would think it would, but it doesn't). You'll need to make use of NSCollectionViewItem (create a custom subclass) and update your WebView's URL when its represented object is changed.
The quick start guide you referenced does not show how to use a custom collection view item (it shows a very basic case). You'll need to delve a little deeper into the documentation (and online examples) to achieve your goal.
I would offer one thought to consider regarding your overall goal: WebView is a "heavy" object, so keep your performance expectations realistic regarding creating many of these views.

Resources