nsdictionary

NSArray Returning String Instead of Dictionary

自作多情 提交于 2019-12-12 03:43:34
问题 I've setup logs and checked the code and NSArray is being returned as a string instead of a dictionary. The problem is that I'm not sure how I can convert this particular string into a dictionary and I'm running on a tight timeframe. Here's the code: NSArray* placeJson = [NSJSONSerialization JSONObjectWithData:jsonResponse options:kNilOptions error:nil]; for (NSDictionary *placeJsons in placeJson) { NSLog(@"%@",NSStringFromClass([placeJsons class])); page = placeJsons[@"page"]; NSLog(@"%d"

Argument Type 'AnyObject' does not conform to expected type NSCopying

末鹿安然 提交于 2019-12-12 03:36:45
问题 I am trying to use NSDictionary in Swift and I am facing the above-mentioned problem. I have a dictionary of the following format: let xyz: NSMutableDictionary = ["1":[1,2,3,4,"1","n","1","2"],"2":[1,2,3,4,"+","o","6","2"]] I want to iterate over keys in the dictionary and extract the 6th element of the array. I tried the following; but did not meet with any luck: for keys in dictKeyMutableDict { let xCentVal = xyz[keys as! [NSCopying]][6] } I keep on receiving a subscript error and if I

firebase json deserialization swift

痴心易碎 提交于 2019-12-12 03:35:28
问题 I have JSON data I need entered in a dictionary and then appended to an array. Below is where that should take place, but I get the error this class is not key value coding-compliant for the key K0tA3yTnxAWxCFBZoeyAjcr3yYy1.' let room = rooms[indexPath.row] if let dictionary = room.members { let user = User() user.setValuesForKeys(dictionary) liveCell.members.append(user) } Below are the classes User class User: NSObject { var email: String? var name: String? var profileImageUrl: String? }

UITableView Dynamically Create Sections from NSArray

我是研究僧i 提交于 2019-12-12 03:26:17
问题 I have the following data structure, which I cannot change (probably the most important part of this question): <?xml version="1.0" encoding="us-ascii"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array> <dict> <key>FirstName</key> <string>John</string> <key>LastName</key> <string>Adams</string> </dict> <dict> <key>FirstName</key> <string>Henry</string> <key>LastName</key> <string>Ford</string> </dict> </array>

Iterate through NSDictionary and save it into an array of object type

别来无恙 提交于 2019-12-12 02:49:24
问题 As the title states, I would like to iterate through a NSDictionary and save the single entries into an array of object type. I am currently struggling to read out the single entries of the NSDictionary, as I cannot simply call them with entry[index] and count upwards. I've got a local JSON file named "Clients", which I get into swift. The file looks like this: { "clients": [ { "id": 3895, "phone": 0787623, "age" : 23, "customerSince" : 2008 }, { "id": 9843, "phone": 7263549, "age" : 39,

how to sort array from fetch by valueForKey

谁说胖子不能爱 提交于 2019-12-12 02:46:22
问题 I have a fetchResultController that compiles an array by running through multiple methods. The final cells display a name and number (ranking). I'd like to take the cells from the tableview and sort them by the number (ascending). I've tried nssortdescriptor in the frc but run into issues when I try to call the 'ranking' because it isn't a keypath of the entity I'm fetching. Is there a place I can intercept this array that comes out of the frc to sort by valueForKey:@"ranking"? How would I

Using NSPredicate get only values of a particular key from an array of dictionaries

大兔子大兔子 提交于 2019-12-12 02:23:55
问题 I do not know the values. I only know the key. arrTripCat : ( { tripcategory = "general_tourism"; }, { tripcategory = nightlife; }, { tripcategory = "art_museums"; }, { tripcategory = nightlife; }, { tripcategory = architecture; }, { tripcategory = nightlife; } ); The NSPredicate I tried : NSArray *arrTripCat = [NSArray arrayWithArray:[self.dictSearchResult objectForKey:@"TripCategories"]]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY SELF.@allKeys contains[cd] %@",@

sort on nsdictionary is giving different result than sort on nsarray

无人久伴 提交于 2019-12-12 01:03:03
问题 2 days ago I asked the question how to sort elements by second word in string object and i got solution here but now I stuck into new issue Consider I have nsarray with--> names and nsdictionary with same-->names(of nsarray) as value and email id as key And my nsarray contains "Test Teacher" "Anonymous" "Dok Teacher" and my nsdictionary contains "Dok Teacher" --"a@g.com" "Anonymous" -- "b@g.com" "Test Teacher" --"c@g.com" As I was needed to sort these array and dictionary i sorted them using

Objective C: how to convert nested NSDictionarys and NSArrays to URLEncoded string

Deadly 提交于 2019-12-12 00:32:13
问题 I have a Symfony2 project serving both a JQuery Web client and an Objective C iPhone APP. JQuery sends properly its urlencoded data to the server. Data that is properly accessed in the Symfony2 Controller using $this->getRequest()->get('myKey'); . Therefor, data is sent in application/x-www-form-urlencoded . In order not to change my Symfony Controllers (that happens to be the the whole API of my system and has around 200 AJAX calls in the form I described before), I'd like the Objective C to

copy NSData into int32_t variable

梦想与她 提交于 2019-12-12 00:29:20
问题 I have a big NSDictionary full of entries that are all of type NSData. I have several entries that need to be of type int32_t however I am not 100% sure how to copy the data in the entries of the NSDictionary across.. is it as simple as doing the following - .h //.. int32_t myint; } @property (assign) int32_t myint; //.. .m //.. @synthesize cardID; //.. - (void)assignSearchData:(NSData*)searchData { myint = [searchData objectForKey:@"IntKey"]; } //.. or do I need some type of data conversion