swifty-json

Trouble parsing JSON with Swift using SwiftyJSON

霸气de小男生 提交于 2019-12-08 19:36:00
问题 I am new to swift and I am trying to parse some simple JSON data I am retrieving from a private API that I have. I am using the SwiftJSON library. No matter what I do I cannot assign the variable "videoUploadId" with the value of "video_upload_id" coming from the JSON response. I hope i provided enough info to get some help. Thanks Here is a segment of the code let task = session.dataTaskWithRequest(request, completionHandler: { (data : NSData!, response, error : NSError!) -> Void in if

Realm data Insertion took over 7mins for big size json

孤者浪人 提交于 2019-12-08 08:26:35
问题 I use Alamofire to download big json data which was about around 7MB and use RealmSwift to store data at realmobject and SwiftyJSON to parse.My realm object insertion after it finished download the json seems really slow at insertion.Was something wrong with my bad code?Please guide me. First of all I will show simplest Json : { { "Start" : "40000", "End" : "1000000", "Name" : "Smith", "Address" : "New York" },{...},more than 7000 records... } Here is my AlamofireAPI Protocol import

iOS: Using HanekeSwift with SwiftyJSON

南楼画角 提交于 2019-12-07 15:53:53
问题 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? 回答1: So, the solution that I've found

How to search from array of SwiftyJSON objects?

我的梦境 提交于 2019-12-07 11:22:31
问题 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

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

◇◆丶佛笑我妖孽 提交于 2019-12-07 10:40:56
问题 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

Showing JSON data on TableView using SwiftyJSON and Alamofire

北战南征 提交于 2019-12-07 04:44:10
问题 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

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

北城以北 提交于 2019-12-07 03:28:59
问题 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

SwiftyJSON looping through an array of JSON objects

随声附和 提交于 2019-12-06 23:32:18
问题 [ { "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 回答1: 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) } 回答2: Assuming [{"id":"1", "name":"Kakkad", "cont":"9714494770"},{"id":"2", "name":"Ashish"

Realm data Insertion took over 7mins for big size json

ⅰ亾dé卋堺 提交于 2019-12-06 20:38:30
I use Alamofire to download big json data which was about around 7MB and use RealmSwift to store data at realmobject and SwiftyJSON to parse.My realm object insertion after it finished download the json seems really slow at insertion.Was something wrong with my bad code?Please guide me. First of all I will show simplest Json : { { "Start" : "40000", "End" : "1000000", "Name" : "Smith", "Address" : "New York" },{...},more than 7000 records... } Here is my AlamofireAPI Protocol import Foundation import Alamofire import SwiftyJSON protocol RequestDataAPIProtocol{ func didSuccessDownloadingData

How to append new data to an existing JSON array(swiftyJSON)

冷暖自知 提交于 2019-12-06 19:27:22
问题 I have an array of SwiftyJson data that I have declared and filled it with data .The code I'm using to fill the hoge array is this : self.hoge = JSON(data: data!) but I need to append new swiftyJSON data to this hoge array .I noticed hoge array doesn't have append property . How should I do that? Thanks 回答1: SwiftyJSON does not have append or extend functionality. You can: self.hoge = JSON(self.hoge.arrayObject! + JSON(data: newData).arrayObject!) But I recommend to declare self.hoge as [JSON