nsjsonserialization

displaying JSON data with the help of dictionaries and array

不想你离开。 提交于 2019-12-02 23:19:04
问题 I get the following error [__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x75a8e20 2013-04-20 08:56:14.90 MyApp[407:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x75a8e20' This is my first hands on working with JSON. I get the above mentioned error when I try to run the first piece of code where URL is a flickr url. When I use the photos as key it

post parameter to sever using dictionary swift

烂漫一生 提交于 2019-12-02 15:11:59
问题 I am trying to send data to the server using a dictionary but unfortunately the data is not saving to the database (fields were found to be blank) and I am getting the below response: Optional(["status": true, "msg": successfull]) And also tried to show UIActivityIndicator to user until he got a response but couldn't find a way. Code attempted: let dict = [ "key_one": self.tf1.text!,"key_two":self.tf2.text!] do { let jsonData = try NSJSONSerialization.dataWithJSONObject(dict, options:

displaying JSON data with the help of dictionaries and array

时光怂恿深爱的人放手 提交于 2019-12-02 13:59:26
I get the following error [__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x75a8e20 2013-04-20 08:56:14.90 MyApp[407:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x75a8e20' This is my first hands on working with JSON. I get the above mentioned error when I try to run the first piece of code where URL is a flickr url. When I use the photos as key it print the array and app abruptly quits. #define flickrPhotoURL [NSURL URLWithString: @"http://api

post parameter to sever using dictionary swift

耗尽温柔 提交于 2019-12-02 10:28:09
I am trying to send data to the server using a dictionary but unfortunately the data is not saving to the database (fields were found to be blank) and I am getting the below response: Optional(["status": true, "msg": successfull]) And also tried to show UIActivityIndicator to user until he got a response but couldn't find a way. Code attempted: let dict = [ "key_one": self.tf1.text!,"key_two":self.tf2.text!] do { let jsonData = try NSJSONSerialization.dataWithJSONObject(dict, options: .PrettyPrinted) // create post request let url = NSURL(string: "myAPIUrl.php?")! let request =

fatal error: unexpectedly found nil while unwrapping an Optional value in Swift when tried to parse JSON

£可爱£侵袭症+ 提交于 2019-12-02 08:59:45
问题 I've tried to build up a document-based Cocoa app and when I tried to parse JSON in readFromData: ofType: error: method, I got an error: fatal error: unexpectedly found nil while unwrapping an Optional value . The actual line that caused the error is the following: override func readFromData(data: NSData?, ofType typeName: String?, error outError: NSErrorPointer) -> Bool { var error: NSErrorPointer! var loadedDictionary = NSJSONSerialization.JSONObjectWithData(data, options:

Cannot parsing Json to NSDictionary

自闭症网瘾萝莉.ら 提交于 2019-12-02 08:20:48
I have a WebService, which give me the fallowing Json-String back: "{\"password\" : \"1234\", \"user\" : \"andreas\"}" I call the webservice and try to parse the returned data like: [NSURLConnection sendAsynchronousRequest: request queue: queue completionHandler: ^(NSURLResponse *response, NSData *data, NSError *error) { if (error || !data) { // Handle the error } else { // Handle the success NSError *errorJson = nil; NSDictionary *responseDict = [NSJSONSerialization JSONObjectWithData: data options: NSJSONReadingMutableContainers error: &errorJson]; NSString *usr = [responseDict objectForKey:

fatal error: unexpectedly found nil while unwrapping an Optional value in Swift when tried to parse JSON

六月ゝ 毕业季﹏ 提交于 2019-12-02 06:29:28
I've tried to build up a document-based Cocoa app and when I tried to parse JSON in readFromData: ofType: error: method, I got an error: fatal error: unexpectedly found nil while unwrapping an Optional value . The actual line that caused the error is the following: override func readFromData(data: NSData?, ofType typeName: String?, error outError: NSErrorPointer) -> Bool { var error: NSErrorPointer! var loadedDictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.AllowFragments, error: error) as? NSDictionary // this causes an error return true } It looks like

-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x8943940 while parsing JSON Page to UITableView

不羁的心 提交于 2019-12-02 03:21:22
I have been through many links and fortunately I got many similar links but nothing worked Out. my array is appearing like this in Output, using NSLog().. products = ( { cid = 1; name = "hello world"; }, { cid = 2; name = "It is an array"; }, { cid = 3; name = "error error"; }, { cid = 4; name = "OMG! still same"; }, { cid = 5; name = "any help"; ... ... }, { cid = 130; name = "How is the work going on."; }, { cid = 131; name = "Had a nice lunch"; } ); success = 1 Code to parse JSON, where "news" is an Array var.. - (void)connectionDidFinishLoading:(NSURLConnection *)connection {

How to convert NSObject class object into JSON in Swift?

試著忘記壹切 提交于 2019-12-01 19:08:39
问题 I have var contacts : [ContactsModel] = [] and class ContactsModel: NSObject { var contactEmail : String? var contactName : String? var contactNumber : String? var recordId : Int32? var modifiedDate : String? } Now in contacts I'm having 6 values like Now i want to convert contacts into JSON how can i ? I tried var jsonData: NSData? do { jsonData = try NSJSONSerialization.dataWithJSONObject(contacts, options:NSJSONWritingOptions.PrettyPrinted) } catch { jsonData = nil } let jsonDataLength = "

The Operation couldn't be completed. (Cocoa error: 3840.)

末鹿安然 提交于 2019-12-01 16:13:02
I am trying to parse JSON for an ios 6 app, but can't seem to get it to work. I have scoured tons of forums but haven't found a solution that works, that I understand enough to implement, or that applies. I apologize if there is one that I missed. First I have a test WebService that as far as I can tell returns valid JSON http://thetrouthunter.com/SVLocationsAPI.php Second, here is my Objective-C code: + (NSDictionary *)connectToService:(NSString *)query { NSError *error = nil; query = [NSString stringWithFormat:@"%@&format=json&nojsoncallback=1", query]; query = [query