swifty-json

Alamofire and SwiftyJSON for Swift 2.0

ε祈祈猫儿з 提交于 2019-12-06 12:18:50
I am updating my code for Swift 2.0 for today, however the line var json = JSON(json) gives me the following error Cannot invoke intializer for type 'JSON' with an argument list of type (Result) Do you guys have any idea how should I change my code? @IBAction func changePassword(sender: UIBarButtonItem) { Alamofire.request(.POST, AppDelegate.kbaseUrl + "users/me/password", parameters: ["old_password": self.oldPasswordTextField.text!, "new_password": self.newPasswordTextField.text!, "confirm_password": self.confirmPasswordTextField.text!], encoding: .JSON) .responseJSON { (req, res, json) in

iOS: Using HanekeSwift with SwiftyJSON

醉酒当歌 提交于 2019-12-05 20:16:19
I use Alamofire with SwiftyJSON in my current swift project. I would like to add HanekeSwift for caching. Adding HanekeSwift to the project make it "collide" with SwiftyJSON struct JSON. Is there any easy way to use both of these frameworks? I know there is a option to rename one of the JSON structs but seems like a stupid workaround. Or do some namespace thing. Error message: 'JSON' is ambiguous for type lookup in this context Any solutions to this? So, the solution that I've found works for me is just to declare the full type of JSON object you are trying to use. E.g. - declare SwiftyJSON

ResponseSerializer 'cannot call value of non-function type 'NSHTTPURLResponse?'' with Swift 3

夙愿已清 提交于 2019-12-05 17:08:05
I had been using the following code without issue until updating to Xcode 8 beta 6. It is similar to this example from the Alamofire repository. This morning I updated my Alamofire library to the latest swift3 branch, which is now compatible with beta 6. It shows the error: Cannot call value of non-function type 'HTTPURLResponse?' A similar question exists here , but it is not based on the current version of Swift and Alamofire. From what I understand, this error is because it thinks that I am trying to return the Request property response instead of the function response(responseSerializer:

How to create objects from SwiftyJSON

半城伤御伤魂 提交于 2019-12-05 14:51:23
问题 I have a code, that parses JSON's list of questions and I can get every property. How can I iterate through the whole file and for each question create an object ? class ViewController: UIViewController { var hoge: JSON? override func viewDidLoad() { super.viewDidLoad() let number = arc4random_uniform(1000) let url = NSURL(string: "http://www.wirehead.ru/try-en.json?\(number)") var request = NSURLRequest(URL: url!) var data = NSURLConnection.sendSynchronousRequest(request, returningResponse:

How to search from array of SwiftyJSON objects?

断了今生、忘了曾经 提交于 2019-12-05 14:16:30
I have an SwiftyJSON object. How to search by key(name) from the array of SwiftyJSON object. For Example : let arrCountry = [JSON]() Now one country array contains { countryid : "1" name : "New York" }, { countryid : "2" name : "Sydeny" } How to search by predicate or something? If I search "y" from the array then it should return both object (Because both contains "y") in another JSON array. And If I type "Syd" then it should return only one object in JSON array. As LIKE query in SQL. And as we are doing with predicates... Get the array from the JSON object with arrayObject , cast it to the

Showing JSON data on TableView using SwiftyJSON and Alamofire

守給你的承諾、 提交于 2019-12-05 10:40:51
I want to show the JSON data grabbed from a server on a Table View. The problem is, I can't get it to show up on it. I have tried several different methods and searched a lot to find a solution, but I can't. My code (all of it) is shown below and I hope somebody can help me out. Thanks in advance. import UIKit import Alamofire import SwiftyJSON class MasterViewController: UITableViewController { var tableTitle = [String]() var tableBody = [String]() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. getJSON() } func

dyld: Library not loaded: @rpath/SwiftyJSON.framework/SwiftyJSON

核能气质少年 提交于 2019-12-05 07:51:04
I've been using the simulator to test my app. Today I decided to test it using other devices in the simulator and to my surprise it crashes on startup on some devices, on others it works perfectly My app builds an runs on : iPad Air resizable iPad iPhone 5S iPhone 6 iPhone 6plus resizable iPhone My App crashes on: iPad 2 iPad Retina iPhone 4S iPhone 5 The Error I'm Getting is : dyld: Library not loaded: @rpath/SwiftyJSON.framework/SwiftyJSON Referenced from: /Users/data/Library/Developer/CoreSimulator/Devices/2ACCFF1F-D35F-444A-B709-2A41AC9CC7D2/data/Containers/Bundle/Application/DA7480F6-4032

SwiftyJSON looping through an array of JSON objects

眉间皱痕 提交于 2019-12-05 02:58:42
[ { "cont": 9714494770, "id": "1", "name": "Kakkad" }, { "cont": 9714494770, "id": "2", "name": "Ashish" } ] The one above is a json array filled with JSON objects. I don't know how to parse through this with SwiftyJSON Example from the SwiftyJSON page, adapted to your data: let json = JSON(data: dataFromNetworking) for (index, object) in json { let name = object["name"].stringValue println(name) } Assuming [{"id":"1", "name":"Kakkad", "cont":"9714494770"},{"id":"2", "name":"Ashish", "cont":"9714494770"}] is assigned to a property named jsonData. let sampleJSON = JSON(data: jsonData) let

How to sort JSON coming from Alamofire and return final JSON object (swiftyJSON)

最后都变了- 提交于 2019-12-04 17:10:47
I'm having trouble succinctly pulling data from an api, adding the users current location into the object and then sorting the data based on the calculated distance. The stackoverflow questions don't quite answer the problem I'm facing. See here: How to sort posts read from JSON server file in Swift . I'm currently loading api data from Alamofire and rendering that data with a UITableViewController. override func viewDidLoad() { super.viewDidLoad() titleLabel.title = q.capitalizedString Alamofire.request(.GET, "http://www.thesite.com/api/v1/things", parameters: ["q" : q]) .responseJSON {

NSDictionary to json string to json object using SwiftyJSON

岁酱吖の 提交于 2019-12-04 11:54:02
问题 I have a use case where I have an array of dictionaries and I need them as a json object: var data = [Dictionary<String, String>]() //append items var bytes = NSJSONSerialization.dataWithJSONObject(data, options: NSJSONWritingOptions.allZeros, error: nil) var jsonObj = JSON(NSString(data: bytes!, encoding: NSUTF8StringEncoding)!) println(jsonObj) println(jsonObj[0]) The first print statement gives me [ {"price":"1.20","city":"Foo","_id":"326105","street":"One"}, {"price":"1.20","city":"Bar","