I have really huge problem with these 3. I can't them distinct. I know that are libraries and cooperate with themselves . It seems to me that all three make the same , I mean retrieve data from Internet. Could you explain me what's going on with these three?
REST(Representational state transfer): It is a framework which provides you a way of communicating between computers using internet. Typically, over an API call. It consists of an Architecture with 6 Constraints (5 Compulsory & 1 Optional). Read more about it here.
JSON(JavaScript Object Notation): This is a standard representation of data exchange. There are other representations like XML which were used for the same. JSON consists of basic data structures in order to pass data over network. It uses String, Number, Array, another JSON Object, null and a Boolean to efficiently represent data.
The above 2 concepts are relevant in any stream or language of computer science.
Alamofire(HTTP Networking library for Swift): This library IS ONLY USED IN iOS APPS WITH SWIFT. It doesn't hold relevance outside this subset. Sure, there is a method of making network calls without using Alamofire in swift. You can read about NSURL, NSURLSession etc. to learn the classic method. The problem with normal NSURL calls is that it is very elaborate to write those calls and can get messy in no time. Thankfully, there is a way of mitigating that mess. Alamofire handles those async calls efficiently and also lets you do cool stuff with the response easily.
NOTE: These 3 are not at all same. REST calls can be made using JSON, XML, URL Encoding etc. JSON can be used in normal JavaScript and not necessarily needs to be passed over a network. and Alamofire exists to just ease the pain of making network calls in iOS.
Hope this helps!
Related
Good Morning,
I am in the process of designing an app. It will capture data in the device and will sync with a web server, I have a few months learning Swift to develope iOS apps and I am learning to use core data now with small samples.
I have a book I've been reading and available resources like this one:
https://developer.apple.com/library/watchos/documentation/Cocoa/Conceptual/CoreData/index.html
My question is:
Do I have to start learning how to sync and save data in the device at the same time? or I can learn Core Data first, make the app and then start the process of syncing (using JSON)?
What available resources can I see to learn what I need?
This is new for me, I have a friend who knows Ruby and has knowledge about API, but he does not know how mobile devices works in this matter.
I have searched here, but a lot of question and answers I see covers specific topics.
Your help and time is really appreciated. Thanks!
P.S.
I apologize for the term sync (send and receive data to/from the server) if I a using it wrong, or should I use the term API? For me is a little confusing on how to use the term, since it is use for a few things, like data, but also it's used when talking about a method which all the info you need to go to the API of the method, function or class.
The process you should follow is first learn basic iOS developemeet. Check out the tutorials at raywenderlich and hacking with swift. In the process you will learn a bit about networking(working with APIs) and Data Persistence(Core Data).
Since collection of data precedes storage of data you must learn first about REST APIs, JSON, JSON parsing and related stuff, third party libraries available like Alamofire and SwiftyJSON(these can be installed using cocoapods)
And then jump into data persistence which can be done through sqlite database(FMDB is a wrapper available and is super easy), Core Data, NSUserDefaults, plist, Realm etc.
I'm working on a simple ResearchKit app that has 20 survey questions, or ORKSteps. How do I get the answers from a participant who submits the survey into a database?
My research has found ORKESerializer and SQLite as potential parts of the solution. I'm missing a big picture view of how these things can be integrated into a working solution.
Starting without knowledge of databases or data transfer from Swift, so any basic information would be very helpful.
How do I extract data from ORKResult using Swift?
Where do I extract the data to? Or, what's the standard type of database for a small survey?
ResearchKit doesn't have any out-of-the-box solution for storing your results. Generally, it's the task of the developer to go through the ORKResult hierarchy and either persist the processed results for later access or send them to a remote server.
You have several options here:
Use NSCoding to store the vanilla ORKTaskResult (with their ORKResult children). This way you can recreate the whole ORKTaskResult hierarchy at later time to inspect or process it.
Use ORKESerializer (as you guessed) to serialize ORKResults into the JSON format. ORKESerializer is currently included as part of ORKTest's unit tests, and it's not documented very well. It's possible that it will be moved to ResearchKit proper in the future, but it's completely usable right now. The JSON format is particularly useful if you want to send your results to any remote server of your own.
You can manually iterate through ORKResults and convert them into objects that are suitable for storing, or into database records. As you said, you could persist them using SQLite; or other database of your choice; or Core Data.
To sum up, there's no recommended or standard method for persisting results, it depends on your needs.
You can also have a look at the official open sourced RK apps. I think they make use of the AppCore library (which sits on top of the ResearchKit) to store the task results (and also use the Sage Bridge to send the results to Sage's servers). But that may be overboard if your needs are simpler.
I suggest that you run the sample ORKCatalog app and then inspect the ORKTaskResult hierarchy (you can do that within the app itself). You'll get an idea of how the result hierarchy looks.
I do not have experience with the Research Kit but as a database you could use sqlite. stephencelis has made a great wrapper for swift which you can use.
I would like to understand the way SWIFT messages work. I tried to understand from Google and it says that it uses packet switched network mechanism.
It would be of great favour if somebody can throw light on the following questions
Whether SWIFT by itself a communication protocol like AS2
For Trade finance system if I use IMEX does using a SWIFT message requires any Adapter kind of components with IMEX
Architecture of SWIFT
How SWIFT works is a big subject, but it's basically a proprietary protocol driven by the needs of the SWIFT community.
Since it all started in the early days of computing, the core stuff uses the UNIX philosophy of: write programs to do one thing, do it well, and use text as your inter program communication.
So, to take FIN messaging, SWIFT works using ASCII text files across a secure network.
To be able to send and receive these text files you need to join SWIFT. See http://www.swift.com/ordering/join_swift
The architecture is proprietary, but, once you join SWIFT you can send and receive specifically formatted text files, or, in the "next generation" it's XML but, to me, that is trying to re-invent the UNIX philosophy, which is bound to fail, and be very expensive in the process. But apparently this is what clients wanted...........?
So there you have it...
I have been tasked with creating an iPhone application for a client.
I have some coding experience but only in C# so it doesn't really help here but other than that I am a complete novice on iPhone coding.
What I am trying to accomplish is to get some form of store locator on a map.
I have successfully added the map, get the user location with it zooming into the user. I have added 2 annotations (Which I believe the the best way to go about showing locations on the map).
I have 2 queries that I need help with, What is the best way to go about listing the stores in some form of database. XML, PList, .sql etc... (this would also need to be read from the web as it would need to be easily edited as new stores would be added a lot). Is it possible to loop through the database and dynamically add the stores onto the map within a location of the user?
I am not asking anyone to write any code for me, I am just asking for some help as I have googled the hell out of this and cant seem to find anything that helps.
Any help would be much appreciated,
Thanks
In terms of your potential formats for saving these locations, you options include:
XML/JSON are good formats for exchanging data with a remote server, but less ideal for a local database (though they theoretically could be used for that purpose). JSON is marginally easier to deal with (using NSJSONSerialization), but XML can be relatively easily parsed, too (using, for example, NSXMLParser). If you're doing network operations, I also heartily recommend looking at AFNetworking, which offers some nice advantages over the standard NSURLConnection. This, of course, presumes that you have written a web service on your server to deliver the necessary JSON or XML feed.
Plist is a fine, simple format if you want to save a short, local list of locations on iOS devices. Saving data to a plist is as simple as calling writeToFile method for your NSDictionary or NSArray and reading data is done via [NSDictionary dictionaryWithContentsOfFile:filename] or [NSArray arrayWithContentsOfFile:filename].
Core Data is a good, iOS-specific format for larger databases. It's probably the preferred iOS mechanism for dealing with persistent objects, but is an order of magnitude more complicated than plists.
SQLite is also a good database format if you're thinking about a structure that lends itself towards larger database, but also which lends itself towards eventual rollout to multiple platforms (e.g. both Android and iOS). If you decide to go SQLite route, consider an Objective-C wrapper (such as FMDB), which will simplify your life greatly.
Implicit in all of the above discussion is that, yes, you certainly can write code that iterates through your database and/or model data structures, extracting the necessary location information, and dynamically add annotations to your map. The Location Awareness Programming Guide should help introduce you to some of the MapKit related features.
"Is it possible to loop through the database and dynamically add the stores onto the map within a location of the user?"
Yes. Just as you have created those first two annotations, you now need to create more annotations in a loop. The only additional info you might need is that once you have added an annotation to the map it will stay there until you remove it. So you don't need to maintain your own list of annotations unless you want to do something else with it. Just fire and forget. So now your question comes down to how to loop through data from your chosen data source in Objective-C and not MapKit specific.
I know this is old but if anyone else comes across this like I did, you can use tmysqlkit by tanmay bakshi to read and write directly to a mysql database on a server.
Best,
Sam
There are a couple of streaming functions and/or classes in iOS/MacOSX. If I wanted to implement my own custom stream i.e. some object that either provides or consumes sequential bytes of data, which of the following API's would be best to use?
Unix file descriptors (int)
No way to implement custom file descriptor?
FILE*
Use funopen to implement own stream.
C-level API, not a lot of Cocoa actually uses this. E.g. cannot bridge this to NSInputStream.
Data can be consumed by your own code
CGDataProviderRef, CGDataConsumerRef
Allows both sequential and direct access read implementations.
Used by CoreGraphics but nothing else.
Data cannot be consumed from your own code
NSInputStream, NSOutputStream
Used by a lot of Cocoa e.g. XML, JSON parsing
Doc allows subclassing, but in practice subclassing is tricky because of asynchronous use.
Data can be consumed from your own code
It would seem NSInputStream/NSOutputStream is the ideal "Cocoa" way of implementing your own stream. However I'm not sure how to implement an App Store-friendly i.e. no overriding of hidden methods (see e.g. http://bjhomer.blogspot.com.au/2011/04/subclassing-nsinputstream.html), subclass of NSInputStream, and either:
(a) make a synchronous-only stream (how do I know whether a particular Cocoa API would consume streams asynchronously and thus not work with my synchronous-only stream?) or
(b) make an asynchronous stream?