I have almost Ten url which provide some data in json formate and XML formate from different site. Now i want call all url asynchronously to use multithreade and i want get one notification when finish all response.So how i can achieve this functionality in ios.
Please help me.
Thanks in advance.
Related
I'm uploading 1900 contacts on my server through a POST API call (AFNetworking). It is taking some time to get a response from the server. During the upload I want to show a progress bar to show an estimated remaining upload time, as I'm not uploading any file , I use json string to post parameters.
Please help me with this, through Google search I could not find any help regarding the upload or download API.
There are multiple answers on StackOverflow already answering your specific use case. For example have a look at this question: get progress from dataTaskWithURL in swift
For your specific use case there are also already answers using AFNetworking: AFNetworking 3.x multipart form upload
To summarize, what you want to do is to
1. calculate the total amount of data you want to upload and the
2. total amount of data you already uploaded via the URLSession delegate methods.
Then you can bind this information to your UI element, for example your UIProgressView. Make sure that your upload tasks are asynchronous in order to have a non blocking upload task and to be able to update your UI while the upload is happening. This also means that other than your upload task your code to refresh the UI should run on the main thread. You can enforce this via DispatchQueue.main.async if needed.
I have a script that takes hours and outputs if it is open or closed and I want to run this on my server, and then from my iOS app get if a certain place is open or closed. And I was wondering how I could do this without generating an JSON file and then parsing that as I would to frequently re-generate the file as the things change from open to closed and such. So is there a way I could make a call to the server and just get the data that I want?
Im not entirely sure whether you are asking specifically for an iOS framework for requests and responses or server side. So I figure I will try to answer both. Here are some swift projects you might be interested in. I'm not incredibly familiar with objective c yet but these resources might prove useful.
Alamofire
This will help you send and receive http requests.
Swifty JSON
This will help with JSON parsing
However if your question is more regarding server side issues. You could look into a REST api and that way you could only request certain entities that you are interested in instead of just sending back the entire batch of information with all of your data, and searching through it on the iOS device.
Hopefully this is somewhat helpful.
If you are only planning on GET-ing some content from the web you can use the NSURL class. NSURL *lru = [NSURL URLWithString:#"http:mywebserver.com"] and then create a new string object from the url with [NSString stringWithContentsOfURL:lru], or any data you would like. If you are trying to hold a session or having more control over the request, I would suggest looking into the NSURLSession class.
I am building my first iOS game. Now I would like to know how many people have played the game, and how many games in total have been played. As far as I know Apple does not show these kind of stats, so I figured the best way to do this is to ping a hidden URL to my webserver every time a users plays a round of the game.
The game I am making is written in Swift. I have tried to find some sample code to ping external URL's, but so far I have not found anything.
Could anyone point me in the right direction?
In my opinion the best thing to do is to use google analytics.
It will give you a lot of statistics (like how many times each screen has been seen etc)
https://developers.google.com/analytics/solutions/mobile?hl=fr
But if you want to do it on your own you can easily call an URL on your web service. Personally I love AlamoFire (https://github.com/Alamofire/Alamofire)
there is a lot of sample on their github page.
You need to configure an external API to connect your swift app with a db running on a server.
In swift, to make pretty request to external services, you can use alamofire. It's a pretty library of the same creator of afnetworking. In a simple way, you can make http networking in Swift. Alamofire only runs for IOS 8 or later.
You need to install alamofire, call the library in your viewcontroler (import Alamofire) and make your request. Read the library documentation, it's clear.
If you are simply trying to hit a url on your website, without passing any data, you can do it very simply by.
let url = NSURL(string: "http://mywebserver.com/secret_end_point")
let session = NSURLSession.sharedSession()
let task = session.dataTaskWithURL(url!)
task.resume()
In my iOS app,I'm sending a post request using the asihttprequest methods and receiving json data.
i want to be able to cache the parsed json data if possible (so that i can directly extract and display in the tableview).
asidownloadcache is helpful only if i'm using GET method. So, i'd like to know my options(along with an example if possible)
Thanks a ton for the help, in advance..
Hi stackoverflow friends
I want to upload text along with image to the webserver. I saw so many examples for uploading images to webserver but nobody explains how to send text from a uitextField along with image.
All of them points this link
http://iphone.zcentric.com/2008/08/29/post-a-uiimage-to-the-web/
This link gives only how to upload images only. I want to send some text values along with this. Could you please send me some example code.
Any help is Appreciable
I recommend you try ASIHTTPRequest. It allows you to easily accomplish such a task. You can create a PHP file that will receive your data via POST - ASIHTTPRequest provides some easy to use methods for this.
See here.
you can Use Evernote API for this purpose