FAQ Database Discussion Community


Need to reload/recalculate NSArray

ios,arrays,database,nsdictionary
I hope someone can help, I'm at my wits end trying to figure this out! Basically I have a JSON feed pulling data into an NSDictionary with an additional file (.h and .m) adding some conditional fields in relation to the current time. I need to update/refresh the conditional fields...

0 randomly becomes 55?

objective-c,swift,integer,nsdictionary
I have an app in which I pass an dictionary of type [string:[int]] from a swift file to an objective c file, then as NSDictionary. Through that process, the data formats get all screwed up, but in the end I am able to access each array of ints from a...

Why I receive warning in objectForKey method?

objective-c,nsdictionary,data-type-conversion
I need to execute method in - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section I have an NSDictionary from which I want to get ID (long) and send it to my method: long sect = (long)section; [objectp.methodA countRowsInSection:[tableSections objectForKey:[NSString stringWithFormat:@"%ld", sect]]] I receive warning: Incompatible pointer to integer conversion sending 'id' to parameter of...

Compare two arrays of dictionaries and add/remove items

ios,objective-c,nsarray,nsdictionary
I have two arrays of dictionaries like this arrCurrent = [{ id = 1; name = "Name1"; },{ id = 2; name = "Name2"; },{ id = 3; name = "Name3"; }]; arrUpdated = [{ id = 1; name = "Name1 has changed"; },{ id = 2; name = "Name2...

JSON Parsing : Retrieving data from the NSDictionary and storing it in an array

ios,json,parsing,nsdictionary
{ Address = ( { address = "Bengaluru, Karnataka 560008, India"; "address_id" = 29; "address_title" = ""; "building_name" = ""; latitude = "23.95579108"; longitude = "77.64169808"; "user_id" = 13; }, { address = "Bengaluru, Karnataka 560008, India"; "address_id" = 31; "address_title" = ""; "building_name" = ""; latitude = "22.95578162"; longitude...

-[__NSDictionaryI isNSString__]: message sent to deallocated instance

ios,objective-c,nsdictionary,writetofile
I am stuck on this for over a week now, and apparently nobody has reported this issue before on stackoverflow. Please read my description carefully before referring me to other postings, because I have read them all and none of them has my answer. I have an NSDictionary containing an...

get var from an array

ios,objective-c,facebook-graph-api,nsarray,nsdictionary
Using that code I'm able to get all the list of array. Looking a lot of tutorial but I'm not able to get the var called "id" if the "name" isEqual to "Timeline Photos". Code: NSArray *feed =[result objectForKey:@"data"]; for (NSDictionary *dict in feed) { NSLog(@"%@",dict); } Result (Example of...

Convert this to javascript

javascript,json,swift,nsarray,nsdictionary
I have some Swift code that needs to be written in javascript. I am not sure how to do this. jsonresult is the json data. Can anyone help? let results: NSDictionary = jsonresult["results"] as! NSDictionary let collection1: NSArray = results["collection1"] as! NSArray for item in collection1 { Thanks...

Access data from NSDictionary

ios,json,swift,nsdictionary
I'm trying to get data from an NSDictionary in Swift but I'm not able to do this. Here is the code let urlPath = "http://ws-report.goocity.it/Stats/json/GetReport" let url: NSURL = NSURL(string: urlPath)! let session = NSURLSession.sharedSession() let task = session.dataTaskWithURL(url, completionHandler: {data, response, error -> Void in var result: NSDictionary if...

How to parse XML from web services into NSArray in Objective-C

ios,objective-c,xml,nsdictionary,nsxmlparser
I am trying to parse this xml to my application, but my NSDictionary is always nil when I debug This xml <DADOS_MESA> <MESA> <Id>1076</Id> <Date>2015-05-08T09:44:25.343</Date> </MESA> <DADOS_MESA> I am requesting this XML from my WS, with NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://myIP/Services.asmx/GetDetails?CId=02&SId=01"]]; Then I create an NSDictionary NSDictionary *xml =...

Traversing a dictionary in swift

json,swift,nsdictionary,xcode6.1
I am new to swift and trying to call the web service which result's JSON data. It's structure is as: { temp : [ { key1:value1 key2:value2 key3:value3 } { key1:value1 key2:value2 key3:value3 } { key1:value1 key2:value2 key3:value3 } ] } I am able to get the resultant JSON. But...

Why should I not be using [NSDictionary objectForKey:]?

objective-c,nsdictionary
I recently started using Faux Pas (http://fauxpasapp.com/), and for my project I get the following warning a number of times: Old, verbose Objective-C syntax -[NSDictionary objectForKey:] is called. Consider using an Objective-C subscript expression instead. I'm unsure what the subscript expression is, and I'm not having much luck finding anything...

how to retrive JSON data by using swift

json,swift,nsdictionary
I am retrieving datas from JSON by using swift. I am new to JSON. I don't how to retrieve this nested values. My previous question is Issue raised, while retriving datas from JSON by using swift . I got clarified. This is new to me. My JSON format is below....

Count Parents tag in JSON file iOS

ios,objective-c,json,nsdictionary
Actually I am going to make a project where some Emoticons will show in some UIView & user first have to download those files (image & JSON) from server. This is my JSON file: (it is not fixed, may be more Parents tag "Frames", will add in future) { "Frames1":...

Parsing a Dictionary of Arrays from a Plist file

ios,objective-c,nsarray,nsdictionary
I am trying to work with a specific data layout. We use a plist file which is setup in the following way: Root (Dictionary): - 1.1 (Array) -- Item 0 (Dictionary) --- Title --- Icon -- Item 1 (Dictionary) --- Title --- Icon - 1.2 (Array) -- Item 0 (Dictionary)...

Not all keys work when converting JSON String to NSDictionary

ios,objective-c,json,nsdictionary,nsdata
I'm using the following code to convert a JSON string literal to an array holding an NSDictionary for each item: NSString* json = @"[{\"name\":\"Item 1\",\"id\":\"999\",\"lang\":\"en\",\"type\":\"A\",\"version\":15}]"; NSData* data = [json dataUsingEncoding:NSUTF8StringEncoding]; NSArray* values = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]; After removing the app from my test device, the app started crashing when...

ios issue with NSDictionary retrieving value from key

ios,objective-c,nsdictionary
I have the following few lines: NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:&error]; if (error) { NSLog(@"Error serializing %@", error); } NSLog(@"JSOND: %@", JSON); NSString *valueFromKey = [JSON objectForKey:@"backseatBucks"]; NSLog(valueFromKey); NSLog(valueFromKey.class); The first NSLog will print: JSOND: { backseatBucks = 5; } However it seems to be erroring on the...

Obj-C setValuesForKeysWithDictionary 64-bit vs 32-bit

ios,objective-c,json,nsdictionary,32bit-64bit
I am pulling a JSON object from my API and creating it using the following code (in hindsight not the way to go): + (YActivity *)instanceFromDictionary:(NSDictionary *)jsonDictionary { YActivity * instance = [[YActivity alloc] init]; [instance setAttributesFromDictionary:jsonDictionary]; return instance; } - (void)setAttributesFromDictionary:(NSDictionary *)jsonDictionary { if (![jsonDictionary isKindOfClass:[NSDictionary class]]) { return;...

Cannot subscript a value of a type AnyObject, in Swift

json,swift,nsdictionary
I have this line of code, and I want to extract the "title" key: var title = jParams["title"] as! String However it wont let me compile, and if I get this error message in red: Cannot subscript a value of a type AnyObject with an index of type String When...

Adding dictionary in plist file

ios,objective-c,xcode,nsdictionary,plist
I need to add items in my plist (organizations.plist) My plist is organized in the following way: I have a root dictionary, and in this one, I have others dictionary... <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>1</key> <dict> <key>Address</key> <string>Address</string> <key>City</key> <string>City</string>...

NSPredicate filtering an array based on a localised string entry

ios,nsarray,nsdictionary,nspredicate,nslocalizedstring
We have a main plist file, which includes our data source. The above shows an example of one sub dictionary from the root array. I would like to create an NSPredicate to search/filter the Category Name. But not the value in the plist as this is a localized string key....

Filling an array with NSDictionary

ios,objective-c,uitableview,nsdictionary
I have NSDictionary that get it data from JSON and now i want to mange that data and populate tableView. However, i face unpredicted obstacles. My point is - to make an arrays and methods with proper values (arrays of images, of text values, etc.). Currently I'm using AFNetworking. In...

Apple watch communicate with iOS app a new swift project vs to existing obj c project

objective-c,swift,nsdictionary,apple-watch
1) I've managed to communicate from apple watch to iOS app using a complete swift project (iOS app in swift and Apple Watch target in swift) Code: In InterfaceController.swift @IBAction func buttonPressed() { let watchMessage = ["SiteName" : "Tech-recipes"] WKInterfaceController.openParentApplication(watchMessage, reply: { (reply:[NSObject : AnyObject]!, error: NSError!) -> Void in...

How initWithObjectAndkeys using variable in iOS

ios,objective-c,json,xcode6,nsdictionary
How initWithObjectAndkeys using variable, I want loop through for no of items in category, please help if I use NSArray like this data = [saved_result valueForKey:@"data"]; NSLog(@"%@",[data valueForKey:@"category"]); NSArray *myArray = [[NSArray alloc]initWithObjects:data, nil]; for (id tempObject in myArray) { NSLog(@"Single element: %@", tempObject); } here is the content of...

How can I correctly set and use a Dictionary?

ios,swift,dictionary,nsdictionary
I want to set this structure: 0:[ "name"="My Name", "description"="Some Description" ], 1:[ "name"="Some Name" "description"="Some other Description" ] ] Here is how I am initiating my dictionary: var topStandbyUsers = [Int:[String:String]]() Here is how I am setting it (also errors here): self.topStandbyUsers[0] = ["fullname"="My Name","description"="Some description"] // this gives...

Xcode Duplicate NSDictionary

ios,objective-c,xcode,dictionary,nsdictionary
I am having an issue with two dictionaries. In my header file I declare a dictionary: @property (strong, nonatomic) NSMutableDictionary *templateDictionary The templateDictionary holds strings and dictionaries, such as 'blankCopy', which in turn holds other strings and dictionaries. I am also declaring a dictionary within my implementation file: @property (strong,...

Send NSString as body of post method using NSURLSession

ios,objective-c,nsstring,nsdictionary,nsurlsession
I am trying to post a string to a server using the next example: // 1 NSURL *url = [NSURL URLWithString:@"YOUR_WEBSERVICE_URL"]; NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration:config]; // 2 NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; request.HTTPMethod = @"POST"; // 3 NSDictionary *dictionary = @{@"key1": @"value1"}; NSError...

Storing dictionaries into Firebase?

ios,swift,firebase,nsdictionary
I have a Firebase instance where I want to store a dictionary of values I want to store into firebase. I have looked on the documentation https://www.firebase.com/docs/ios/guide/saving-data.html as a reference but can't seem to get it to work. The following is my attempt: //Declared above are the currentUser values as...

Custom object to NSMutableDictionary

ios,nsdictionary
I would like to add a custom object to NSDictionary. It should store three variables: two strings and a boolean. I read around the net and found NSCoder to be the way but I dislike the result. By using [dictionary setObject:[NSKeyedArchiver archivedDataWithRootObject:customObject]] I end up with NSData information instead of...

EXC_BAD_ACCESS with NSDictionary/CFDictionaryRef

objective-c,nsdictionary,exc-bad-access
I've got the following piece of code : (it's long) //declarations (in the header) : NSDictionary* batteryRawDict; @property (strong, atomic, readonly) NSDictionary* batteryReport; //this dictionary is, obviously, @synthesize'd case PFSKGroupBattery: { //to get more informations or to subscribe for events about power sources, use the IOPowerSources API if (!firstRunDoneForBattery) {...

“Extra argument 'foo' in call” OR “'[NSObject : AnyObject]!' is not a subtype of 'Dictionary'”

objective-c,swift,nsdictionary
I've read all the "extra argument in call" posts I can find, but am still banging my head against this one. I have a method that looks like this: // Objective-C + (void)get:(NSString *)url params:(NSDictionary *)params completion:(NetworkCompletion)completion // Swift autocomplete GenericWebService.get(url: String!, params: [NSObject : AnyObject]!, completion: (([NSObject : AnyObject]!,...

Translate an array of NSdictionnary with NSlocalizedstring

ios,arrays,swift,nsdictionary,nslocalizedstring
I have an array of NSdictionary like this let section1 = [NSDictionary(objects: ["English base language test", 2], forKeys: ["title", "value"]) ] let section2 = [NSDictionary(objects: ["English Base Language test2", 2], forKeys: ["title", "value"]) ] (I have more objects but for this post i'll just put 1 in the sections) and...

Using map on NSDictionary

swift,closures,nsdictionary
SETUP I am loading data from my server by using my API The returned data is in JSON The JSON provided by the API is pictured below I use ALAMOFIRE to receive the data from the API and parse the JSON response JSON { data: [ { owner: "FREDL", street:...

How to get the same data like json in NSDictionary

json,swift,nsdictionary
I am having trouble with NSDictionary that i generated from my json.I dont know whats wrong with my NSDictionary which mean i dont get the same sorted keys like json in my NSDictionary when i tried to output it.Please help Here is my json that i tested in intellij IDEA...

Return value of object in NSDictionary with several keys

ios,json,nsdictionary
I am getting a string from a NSURLRequest. Then I am deserialising the string to convert it to a NSDictionary as follows: NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; if(responseString && responseString.length) { NSLog(@"%@", responseString); NSError *jsonError; NSData *objectData = [responseString dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary *json = [NSJSONSerialization JSONObjectWithData:objectData options:NSJSONReadingMutableContainers error:&jsonError]; NSLog(@"STRING...

Sort NSArray by other NSMutableDictionary

ios,objective-c,uitableview,nsdictionary,nssortdescriptor
I have a NSArray called objects. This array could look like this: [0] "name" => blaBlaBla "foo" => b "bar" => c [1] "name" => bluBluBlu "foo" => b "bar" => c I also have a NSMutableDictionary, which changes every second. This will look like this ['blaBlaBla'] "sortValue" => 1...

How to store multiple values for the same key in an NSDictionary, given an NSArray of JSON objects?

ios,objective-c,json,nsarray,nsdictionary
I know it's not possible to set multiple values for the same key, unless the values are stored in an array. I have this NSArray called friMainDicArray of JSON objects: { day = 0; "end_time" = "17:30"; "english_event" = "Lion Dance"; "english_performer" = "Legendary Group"; "image_link" = "schedule_miss_vn"; stage =...

Retrive specific JSON key from subcategory

ios,json,nsarray,nsdictionary
I'm retrieving data only once from the server as JSON on my TableView and it is working fine. I couldn't print a specific subject from the JSON. For example according to my JSON I just want to print the name's of the Dining Room or Coffees without Bedroom. How I...

Error tells me that my textview is nil when trying to make NSDictionary

ios,objective-c,xcode,constraints,nsdictionary
I am about to set up some constraints in my app. When i try to make an NSDictionary i get the error that tells me that my UITextView is nil. As you can see i have set some preferences for my UITextView, so i would presume that it isn't nil....

how to search and replace in NSDictionary?

ios,objective-c,nsdictionary
I have a JSON that I converted into NSDictionary and now I want to search and replace some values in it but I have no idea how to to this, { "CODE":200, "APICODERESULT":"USER_INTERESTS", "MESSAGE":"user interests fetched successfully", "VALUE":{ "Books":[ { "key":"7", "value":"Fiction", "selected":true }, { "key":"8", "value":"Romantic", "selected":true } ],...

Order an Array/Dictionary in objective c [duplicate]

ios,objective-c,json,uitableview,nsdictionary
This question already has an answer here: How can I sort an NSArray containing NSDictionaries? 3 answers I am trying a little project where I get the current location coordinates, then by the current location I find coffee shops nearby and display them in a UITableView. So far I...

NSDictionary and UITableView subtitle

ios,objective-c,uitableview,nsdictionary,subtitle
I am trying to make a phone book like application in Objective-C. I use NSDictionary to populate my UITableViewCell. I got the title, index, and the sections right but, I can not get the right subtitle for each title. It is always the same subtitle for every title. Here is...

File with string in JSON format , how to read filecontent into NSDictionary

ios,json,file,nsdictionary
I have a file-"xyz.txt" in my applicaion bundle with just JSON formatted text. I want to open the filepath of the text file and read the content to NSDictionary. How to do that. I already have my JSON string ready. Just need to initliaze to NSdictionary. If I directly initilize...

Swift Dictionary confusion

swift,nsdictionary
Say I have var dict = parseJSON(getJSON(url)) // This results in an NSDictionary Why is let a = dict["list"]![1]! as NSDictionary let b = a["temp"]!["min"]! as Float allowed, and this: let b = dict["list"]![1]!["temp"]!["min"]! as Float results in an error: Type 'String' does not conform to protocol 'NSCopying' Please explain...

Simple Way to Access Within JSON NSDictionary Object Values in Swift?

ios,json,xcode,swift,nsdictionary
So I have called a rest API Web Service in Swift and I have my response as an NSDictionary but I am not sure the easiest way to directly access the items within the dictionary. I have included a screen shot. Showing the structure of the response. The elements I...

Swift: How to make a selected cell NSLog the corresponding value and key from a dictionary

swift,nsdictionary,tableview
I have a TableViewController that is populated by a dictionary. My goal is that when I click a cell from the tableView it will NSLog the cell's name from the dictionary as well as the corresponding value. For example if I have a dictionary: var profiles = ["Joe": 1, "Sam":...

How to restructure object of NSDictionaries

ios,objective-c,nsdictionary
In my debugger this is how my log statement is printing my messages object: self.messages = ( "<lean: 0x7fcf98665140, objectId: vglE1UJ5KI, localId: (null)> {\n messageBody = Jj;\n recipientId = XvvxETqjph;\n senderId = XvvxETqjph;\n timestamp = \"1424991590106.210938\";\n}", "<lean: 0x7fcf98667940, objectId: rgBFYBMKlU, localId: (null)> {\n messageBody = \"test 3 from ian\";\n recipientId...

Add a permanent NSDictionary to ios app

ios,objective-c,iphone,xcode6,nsdictionary
I am building a Railway app for iPhone. The app lists some Train Stations around the user in one of the views. But I don't want to always ping the server, for accessing data that will not change. What I intend to do here is, to create a dummy application...

How to retrieve specific id from JSON tree

ios,json,nsdictionary
I can print the sub_category and products in the tableView and it is working fine but I couldn't print for specific detail for id, for example how can I print the details for products_id=213 to get name,image,model? My table view looks like this [categories>name] then [sub_category>name] then I need the...

Parse Nsmutabledictionary and extract value

ios,objective-c,json,nsdictionary,nsmutabledictionary
Hello everyone i have one problem in parsing a dictionary here is dictionary { "@id" = 10; activityLocation = ""; activityPriority = 1; actualEndDate = "<null>"; actualStartDate = "<null>"; children = ( ); } i am getting this responce in json and when i tried to parse this dictionay and...

Getting error related to NSDictionary object type

ios,objective-c,nsarray,nsdictionary,nspredicate
I want to filter list of countries based on either Country name or Country ISD code. For example, if user types '9', India should be added to filtered array because ISD code of India is "+91". My datasource contains all the information like country name, ISD code etc.. Here is...

How to get a specific object from data structure based on Index

ios,objective-c,nsarray,nsdictionary
I am creating a custom UIPageViewController which uses a custom setup. The data structure that I have is parsed into the following format: { "1.0" = ( { detail = "Detail 0"; icon = "Pull to Refresh"; title = "Item 0"; }, { detail = "More easily refresh a subscription...

NSDictionary and string literal keys

ios,objective-c,nsstring,nsdictionary,nsmutabledictionary
Does using a string literal like @"key" in setObject(id):forKey(id) only work because the compiler optimizes all instances of the string literal to point to the same object? Or does retrieving an object with objectForKey(id) actually compare the string value of the key? What if the NSDictionary was created by an...

Error Store NSdata to NsDictonary

ios,nsdictionary,nsdata
plz help me to parse JSON data. we get response in NSMutable Data. but we cn't take out data in Dictionary. my jsonDictionary get nil. this is my Url . i have check on JSON Validator.They show Valid Json output. help.... http://mobileapp.merucabs.com/NearByCab_ETA/GetNearByCabs.svc/rest/nearby?Lat=23.0768222&Lng=72.645732&SuggestedRadiusMeters=5000&CabMaxCount=10 -(void)connectionDidFinishLoading:(NSURLConnection *)connection { // NSString *responseString = [[NSString...

Getting JSON Sub Category Element Issue

ios,nsarray,nsdictionary
I'm retreving JSON data and I've some categories name with sub_category and other without =0. I can get the categories name and it is working fine but I couldn't get the name in the sub_category, It is getting crash when I call _arraySubCategory Error: reason: '-[__NSCFArray objectForKey:]: unrecognized selector sent...

Populating Custom TableViewCell from Twitter using JSON Serialization

objective-c,uitableview,nsdictionary,tableview,nsjsonserialization
I am new to Objective-C. I spent countless hours being stuck on getting a blank tableview, I am desperate at this point. I am loading twitter data through a JSON call, using their API. I store everything in a NSDictionary, run a for loop to select only "text" values. I...

Convert NSDictionary to NSArray

ios,objective-c,uitableview,nsarray,nsdictionary
I'm trying to convert my NSDictionary (storageData) to an NSArray, as I need to pass the data (title) contained in the dictionary through a segue. I've implemented the below (see last method, the tableview is simply to provide some context), but a crash occurs with the following error: Terminating app...

Get NSString as NSArray from NSDictionary

ios,objective-c,iphone,nsarray,nsdictionary
I've the following data in NSDictionary for an object field_names that has below value. {dBur0z9,nr8r0,R0ru,jrurw,qB5rz9ry},{gr2,Z5uzr,Rwxyr5z0Ar5},^~gr2~cry69v~br9rtyz~Z03r4rsru^~Z5uzr~Uvy3z~dB4srz^5B33,(),9ruI,evD3rsv3,,HLK,evDsBAA65,evDtyvt2s6E,5B33,5B33,5B33,5B33,{6ww},SRiTfUV,5B33,5B33,5B33,5B33 I'm trying to get it as NSArray. I tried `NSArray *array = [dictionary objectForKey:@"field_name"]; But that returns an NSString not an NSArray. Then I tried to replace { } with [ ] and appended [...

Parsing Json Output correctly

ios,objective-c,json,nsdictionary
I am trying to correctly target the elements within the Json Output and I am getting closer but I presume there is a easy and obvious way I am missing. My Json looks like this with a upper level event. JSON SNIPPET UPDATED chat = ( ( { Key =...

Cannot override initializer of NSDictionary in Swift

swift,nsdictionary,swift-extensions
I'm trying to extend the class NSDictionary in Swift to contain an NSDate that is set on init(). When I add my custom init(), I get the complier error: 'required' initializer 'init(dictionaryLiteral:)' must be provided by subclass of 'NSDictionary' However, when I add that initializer using auto-complete, I get the...

get array from dictionary from NSMutableArray iOS

objective-c,iphone,ios8,nsmutablearray,nsdictionary
I have NSMutableArray (self.temporaryArray). How to get "options" key array from dictionary from self.temporaryArray in nsmutablearray. There is console data. self.temporaryArray..( ( { "option_group" = 0; options = ( "<font face=Arial size=2>English</font>\"", "\"<font face=Arial size=2>Both English &amp; German</font>\"", "\"<font face=Arial size=2>Both English and French&nbsp;</font>\"", "\"<font face=Arial size=2>Only German</font>\"", "\"<font face=Arial...

Parsing JSON into a usable format

swift,nsarray,nsdictionary,nsurl
I'm currently downloading data from a server and I'm not sure how to get the response that I'm getting back into the format that's expected by the method that I'm working with. Could someone guide me on what I would need to do to get all of the items in...

Update/change values of NSDictionary keys stored in NSArray

objective-c,nsarray,nsdictionary,segue,nspredicate
I have an NSArray containing NSDictionary's of client data. I am using NSPredicate to filter the array and pass it through ViewControllers with segues. I am at a stage where I would like to change some values of the keys stored in the dictionary. How is this achievable? My prepareForSegue...

NSDictionary - Parsing item out of a return JSON service

ios,json,nsdictionary
I'm trying to work with a web service that does some mad stuff. Part of the service is returning a value that looks like this screen shot. Below is my code just trying to loop through an NSDictionary. NSDictionary *platesJson = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil]; for(id key in platesJson) {...

How to efficiently loop through multiple nested NSDictionaries and compare values?

objective-c,xml,nsdictionary
I have the following structure in an NSDictionary that I got after parsing the XMl using XMl reader from here http://troybrant.net/blog/2010/09/simple-xml-to-nsdictionary-converter/: { Document = { Page = ( { TextLR = { Line = { LineProps = { applyBreakingRules = true; autoDecimalTabPos = 0; breakJust = BreakOptimal; direction = ES;...

Error using `NSDictionary` in swift

ios,swift,nsdictionary
I'm very new to swift and im trying to display a collection of images in collection view I get an error with this code let asset: PHAsset = self.photoAsset[indexPath.item] as PHAsset PHImageManager.defaultManager().requestImageForAsset(asset, targetSize: PHImageManagerMaximumSize, contentMode: .ScaleAspectFill, options: nil, resultHandler: { (result: UIImage!, info: NSDictionary!)in cell.setThumbnailImage(result) }) '[NSObject : AnyObject]' is...

Swift: Parsing Json string and populating information into a dictionary

json,swift,nsstring,nsdictionary
I'm currently learning about web services in Swift. I have this URL that shows recent earthquakes and other information regarding it. The code at the bottom is what I have so far, once I run it, it NSLogs a string in JSON format from the URL. Here are 3 records...

Content of a NSMutableDictionnary erratically returned

cocoa,nsdictionary,nsmutabledictionary
I am trying to add keys in a dictionnary in Objective-C. The code is as follows : I have a class MyClass whose header file contains : @property (nonatomic) NSMutableDictionary *dict; This gets initialized as follows : _dict = [[NSMutableDictionary alloc] init]; Then I try to add keys to it...

How to iterate concisely through @properties on an NSObject subclass to set properties from a plist?

cocoa,nsarray,nsdictionary,plist,nsobject
Say I have a subclass of NSObject (let's call it 'BSObject') with the following properties: NSString *name; NSNumber *num; I have an NSMutableArray of BSObjects (let's call that one 'BSCollection'). For storage on disk, I have a property list which is an array of dictionaries. The BSCollection is represented by...

Given a dictionary of numbers, determine which sets contain unique values (i.e. numbers that do not belong to any of the other sets)

ios,objective-c,nsdictionary,unique
Looking for the most efficient way to solve this using Objective-C (and Swift as a second preference). You have a NSDictionary containing the below sets for example. NSDictionary dict = @{ { @"foo", [NSNumber numberWithInt:1] }, { @"bar", [NSNumber numberWithInt:10] }, { @"baz", [NSNumber numberWithInt:11] }, { @"boz", [NSNumber numberWithInt:1]...

Error in adding an element to [String:Array] in Swift

ios,arrays,swift,nsdictionary
I have a property in my model of Type : [String:Array<NSDictionary>]. I want to add elements to this, in a loop. So this is what I do : for var k=0;k<body.count;k++ { var dict=body[k] as NSDictionary if(k==0) { self.model.data[i]!=[dict] } else { self.model.data[i]!.append(dict) } } When I do this, I...

Searching an Array of Strings in Array of Dictionaries

ios,objective-c,nsarray,nsdictionary,nspredicate
I have an array of combinations which needs to be searched in another array of dictionaries Array Of Dictionaries is as follows: self.listOfAllContacts ({ name = "William"; recordId = 541; }, { name = "Soan"; recordId = 541; }, { name = "kamal"; recordId = 541; }, { name =...

Create NSDictionary from Dictionary Log printed by Xcode

ios,objective-c,nsdictionary,nsmutabledictionary
Is it possible to create Dictionary from string data that log area of xcode display. Like 0 = { "Key1" = "ABC"; }; 1 = { "Key1" = "DEF"; }; ...

Deleting the keys and values in NSDictionaries more than the value 100.000 kilometers

ios,objective-c,nsdictionary
I am having a trouble with NSDictionary am adding value as a kilo meters and name as a key this is how am giving NSDictionary * dd = [NSDictionary dictionaryWithObjects:locationKMArray forKeys:nameArray]; NSLog(@"%@",dd); This is how outputs looks like name1 = 1.011115; name2 = 55.14256; name3 = 150.48752; name4 = 22.48668;...

Loading data from nested NSUSERDEFAULTS into UITABLEVIEW

ios,objective-c,uitableview,nsdictionary,nsuserdefaults
I have a DetailViewController which is saving some Data to NSUserDefaults if the user wants. It is like kind of favorite list. Hier is the structure of the saved Defaults: List = { 0002 = ( { Picture = "link to picture.jpg"; Place = "London"; Title = "Flat with Balcony";...

How to downcast to [String: String] in a for in loop?

ios,json,swift,casting,nsdictionary
The type casting section of the Swift programming language guide says it is possible to downcast in a for in loop when we know the item is of a certain type: Because this array is known to contain only Movie instances, you can downcast and unwrap directly to a non-optional...

get const char from nsdictionary

ios,objective-c,char,nsdictionary
I am trying to read const char * from an nsdictionary so far I have tried NSLog(@"input1 %s",(const char*)inInputData); NSMutableDictionary * myDict = [[NSMutableDictionary alloc] init]; NSValue* inputData = [NSValue value:&inInputData withObjCType:@encode(const char)]; [myDict setObject:inputData forKey:@"inInputData"]; NSValue* readVal= [NSValue value:[myDict valueForKey:@"inInputData"] withObjCType:@encode(const char)]; NSLog(@"input2 %@",[myDict valueForKey:@"inInputData"]); NSLog(@"readVal1 %s",(const char*)readVal); NSLog(@"readVal2...

NSDictionary in NSMutableArray ios

ios,objective-c,nsmutablearray,nsdictionary,nsmutabledictionary
I've a NSMutableArray array having NSDictionary keys as: NSMutableArray *arr=@[@{@"A":@{@"user":@"obj1",@"friend":@"obj2"}}]; No I want to add objects to this NSMutableArray. My Code: for (int i = 0; i < 10; i++) { NSString *user = @"A"+i; for(int i=0;i<50;i++) { NSString *friend1 = @"B"+i; NSString *friend2 = @"C"+i; NSString *friend3 = @"D"+i;...

NSJSONSerialization.JSONObjectWithData changes field type

objective-c,swift,nsstring,nsdictionary,nsdata
I'm getting the following JSON response from the server: { "userId":"123456789", "displayName":"display name" } When I use NSJSONSerialization.JSONObjectWithData and then prints the result NSDictionary I see in the console the following: userId = 123456789 displayName = "display name" Why do JSONObjectWithData changes the userId field type from String to a...

Convert String(already formatted) to an Array of NSDictionary

ios,arrays,string,nsdictionary
I have this String already formatted as a [[String:AnyObject]], however I can't retrieve the information out of it nor couldn't find a way to convert it to a dictionary. [ [name: Laura, age:33, gender: female], [name: James, age:25, gender:male] ] What can be done to convert this string into a...

Extracting usable data from an API response in Swift

json,swift,nsdictionary
I picked up a project from a previous dev that kind of left a mess. We've moved to a new API with a better structure and I'm very confused as to how I can get this to work. I've got an API that I'm trying to parse the data from...

How to remove NSDictionary while iterating in NSMutableArray [duplicate]

ios,objective-c,nsdictionary,nsmutabledictionary
This question already has an answer here: Avoiding “NSArray was mutated while being enumerated” 8 answers I want to remove object from array when the name is same. How to do this? Thanks in advance. Here is my code NSString *name1; NSString *name2; NSArray *copyArray = [uniqueArraySort copy]; for...

Converting String into NSDate in array of dictionaries

arrays,swift,casting,nsdate,nsdictionary
I am doing some requests with an API that returns me the following sample : [{ id = 1004; "planning_id" = 7; "started_on" = "2015-05-14";}, { id = 1380; "planning_id" = 8; "started_on" = "2015-05-16";}, { id = 1382; "planning_id" = 8; "started_on" = "2015-05-18"; }] As you can see,...

Error when extracting Json data

json,swift,nsdictionary
I've been extracting data from a local .json file and have changed the code to extract the data remotely, as below GetRemoteData.getDataFromServer { (svrData) -> Void in let jsonDict = NSJSONSerialization.JSONObjectWithData(svrData, options: nil, error: nil) as! NSDictionary for item in jsonDict { var obj = item as NSDictionary for (key,...

Unwrapping Json Swift (found nil)

json,string,swift,nsdictionary,value
i currently trying to decode Json in Xcode, but i not succed to get one of them. This is what i get : [ { "id": "1", "title": "bmw", "price": "500.00", "description": "330", "addedDate": "2015-05-18 00:00:00", "user_id": "1", "user_name": "CANOVAS", "user_zipCode": "32767", "category_id": "1", "category_label": "VEHICULES", "subcategory_id": "2", "subcategory_label": "Motos",...

NSMutableArray adds same NSDictionary multiple times

ios,objective-c,for-loop,nsarray,nsdictionary
I am looping through an array, getting two items and putting them in a dictionary, and then add them to an array, but it keeps adding the last item of the array for the number objects in the array, even though when I log the dictionary inside the loop it...

Why my NSDictionary that was from json sorted like this?

ios,json,swift,sorting,nsdictionary
I am trying to get the same sorted data like json in my NSDictionary when i accept a call. I dont know why i get the data like that? If there is a way, how to do it? Please Help!!

How to access the next key in a Swift dictionary?

swift,dictionary,nsdictionary
I have this code for (k, v) in myDict { println(k) } How do I access the next key in the dictionary (e.g. myDict[k + 1])? Thanks in advance!...

In Swift, what is the effect of having a Type Declaration after the colon? [duplicate]

swift,syntax,casting,nsdictionary
This question already has an answer here: var declaration with type vs without 1 answer So basically, what's the difference between: var temp1 = NSDictionary() var temp2:NSDictionary = NSDictionary() they both work exactly the same. Thank you in advance....